【发布时间】:2023-03-22 14:27:01
【问题描述】:
谁能提示我如何使用 forEach 方法迭代货币数组以获取对象的 ID 和名称。
const currencies = [{
id: 'USD', name: 'US Dollars'
}, {
id: 'UGX', name: 'Ugandan Shillings'
}, {
id: 'KES', name: 'Kenyan Shillings'
}, {
id: 'GHS', name: 'Ghanian Cedi'
}, {
id: 'ZAR', name: 'South African Rand'
}];
var populateCurrencies = (currencies)=>{
currencies.forEach(function(id,name){
}
}
【问题讨论】:
-
我们不是在您的其他问题中向您展示了如何做到这一点吗?
-
你想读取每个对象中的id和name吗?
-
是的@DananjayaAriyasena
标签: javascript arrays object