/*
* Using array destructuring, fix the following code to print the keys and values of the `members` Map to the console.
*/
const members = new Map();
members.set('Evelyn', 75.68);
members.set('Liam', 20.16);
members.set('Sophia', 0);
members.set('Marcus', 10.25);
for (const member of members) {
console.log(member[0],member[1]);
// console.log(key, value);
}console.log(member[0],member[1])是不行的
1 回答
已采纳
牛奶老哥哥
TA贡献204条经验 获得超92个赞
const members = new Map(); members.set('Evelyn', 75.68); members.set('Liam', 20.16); members.set('Sophia', 0); members.set('Marcus', 10.25); for (const member of members) { [key, value] = member; console.log(key, value); }
这样不就好了嘛,望采纳!
添加回答
举报
0/150
提交
取消