Created
December 17, 2022 21:36
-
-
Save Hacking-NASSA-with-HTML/b4d856008fceb75061d364fbb54fd47c to your computer and use it in GitHub Desktop.
Using array destructuring, fix the following code to print the keys and values of the `members` Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
let key | |
let value | |
for (const member of members) { | |
[key, value] = member | |
console.log(key, value) | |
} | |
// The second variant | |
const members = new Map() | |
members.set('Evelyn', 75.68) | |
members.set('Liam', 20.16) | |
members.set('Sophia', 0) | |
members.set('Marcus', 10.25) | |
let key | |
let value | |
members.forEach((value, key) => console.log(key, value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment