10000 Add iterable example · HowProgrammingWorks/Map@527b8be · GitHub
[go: up one dir, main page]

Skip to content

Commit 527b8be

Browse files
committed
Add iterable example
1 parent 1458825 commit 527b8be

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

JavaScript/4-iterable.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
const cityPopulation = new Map();
4+
5+
cityPopulation.set('Shanghai', 24256800);
6+
cityPopulation.set('Beijing', 21516000);
7+
cityPopulation.set('Delhi', 16787941);
8+
cityPopulation.set('Lagos', 16060303);
9+
10+
for (const city of cityPopulation) {
11+
console.log(city);
12+
}
13+
14+
for (const [name, population] of cityPopulation) {
15+
console.log(`Population of ${name} is ${population}`);
16+
}

0 commit comments

Comments
 (0)
0