我有一个数组,我需要按数组值获取一些数据。
"GET /git/repo.git/info/refs?service=git-upload-pack HTTP/1.1" 200 660 "-" "git/2.7.4"
"POST /git/repo.git/git-upload-pack HTTP/1.1" 200 8149 "-" "git/2.7.4"
我需要获取一个对象值数组
let array = ["Clothing", "Home", "Payments"];
const expenses = {
clothing: '#FF9494',
food: '#0099CC',
healthCare: '#C58BE2',
home: '#FF8A00',
recreation: '#669900',
payments: '#CC0D01',
};
答案 0 :(得分:2)
费用是一个对象,这意味着您可以通过键查找属性:
array.map(key => expenses[key.toLowerCase()])