-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaps.html
42 lines (38 loc) · 1.1 KB
/
maps.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Maps</title>
<link rel="stylesheet" href="../base.css">
</head>
<body>
<ul class="prizes">
</ul>
<script>
const person1 = {
name: 'Sharif',
age: 33,
};
const myMap = new Map();
// .set()
myMap.set('name', 'sharif');
myMap.set(20, 'This is a number');
myMap.set(person1, 'Really Cool');
// .get()
console.log(myMap.get(person1));
const prizes = new Map();
const score = 100;
prizes.set(100, 'Bear');
prizes.set(200, 'Duck');
prizes.set(300, 'Car');
console.log(`you win a ${prizes.get(score)}`);
const ul = document.querySelector('.prizes');
for(const [points, prize] of prizes){
const li = `<li>${points} - ${prize}</li>`;
ul.insertAdjacentHTML('beforeend', li);
}
</script>
</body>
</html>