I have a Map that contains keys and their value. I want to convert all keyvalues into an array
JavaScript
โx
15
15
1
const gameEvents = new Map([
2
[17, 'โฝ GOAL'],
3
[36, '๐ Substitution'],
4
[47, 'โฝ GOAL'],
5
[61, '๐ Substitution'],
6
[64, '๐ถ Yellow card'],
7
[69, '๐ด Red card'],
8
[70, '๐ Substitution'],
9
[72, '๐ Substitution'],
10
[76, 'โฝ GOAL'],
11
[80, 'โฝ GOAL'],
12
[92, '๐ถ Yellow card'],
13
]);
14
โ
15
โ
I want that my new array should look like this
JavaScript
1
3
1
['โฝ GOAL','๐ Substitution','โฝ GOAL' ,'๐ Substitution', '๐ถ Yellow card', '๐ด Red card', '๐ Substitution','๐ Substitution',, 'โฝ GOAL', 'โฝ GOAL', '๐ถ Yellow card']
2
โ
3
โ
Advertisement
Answer
this will do
JavaScript
1
15
15
1
const gameEvents = new Map([
2
[17, 'โฝ GOAL'],
3
[36, '๐ Substitution'],
4
[47, 'โฝ GOAL'],
5
[61, '๐ Substitution'],
6
[64, '๐ถ Yellow card'],
7
[69, '๐ด Red card'],
8
[70, '๐ Substitution'],
9
[72, '๐ Substitution'],
10
[76, 'โฝ GOAL'],
11
[80, 'โฝ GOAL'],
12
[92, '๐ถ Yellow card'],
13
]);
14
โ
15
console.log([gameEvents.values()]);