You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 09-Data-Structures-Operators/starter/script.js
+45-2Lines changed: 45 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -156,6 +156,49 @@ GOOD LUCK 😀
156
156
157
157
// 1. Loop over the game.scored array and print each player name to the console, along with the goal number (Example: "Goal 1: Lewandowski")
158
158
159
-
for(let[index,k]ofgame.scored.entries()){
160
-
console.log(`Goal ${index+1}: ${k}`);
159
+
// for(let [index, k] of game.scored.entries()){
160
+
// console.log(`Goal ${index + 1}: ${k}`);
161
+
// }
162
+
163
+
///////////////////////////////////////
164
+
// Coding Challenge #3
165
+
166
+
/*
167
+
Let's continue with our football betting app! This time, we have a map with a log of the events that happened during the game. The values are the events themselves, and the keys are the minutes in which each event happened (a football game has 90 minutes plus some extra time).
168
+
169
+
1. Create an array 'events' of the different game events that happened (no duplicates)
170
+
2. After the game has finished, is was found that the yellow card from minute 64 was unfair. So remove this event from the game events log.
171
+
3. Print the following string to the console: "An event happened, on average, every 9 minutes" (keep in mind that a game has 90 minutes)
172
+
4. Loop over the events and log them to the console, marking whether it's in the first half or second half (after 45 min) of the game, like this:
173
+
[FIRST HALF] 17: ⚽️ GOAL
174
+
175
+
GOOD LUCK 😀
176
+
*/
177
+
178
+
constgameEvents=newMap([
179
+
[17,'⚽️ GOAL'],
180
+
[36,'🔁 Substitution'],
181
+
[47,'⚽️ GOAL'],
182
+
[61,'🔁 Substitution'],
183
+
[64,'🔶 Yellow card'],
184
+
[69,'🔴 Red card'],
185
+
[70,'🔁 Substitution'],
186
+
[72,'🔁 Substitution'],
187
+
[76,'⚽️ GOAL'],
188
+
[80,'⚽️ GOAL'],
189
+
[92,'🔶 Yellow card'],
190
+
]);
191
+
192
+
// 1. Create an array 'events' of the different game events that happened (no duplicates)
// 2. After the game has finished, is was found that the yellow card from minute 64 was unfair. So remove this event from the game events log.
197
+
gameEvents.delete(64);
198
+
console.log(gameEvents);
199
+
200
+
// 4. Loop over the events and log them to the console, marking whether it's in the first half or second half (after 45 min) of the game, like this: [FIRST HALF] 17: ⚽️ GOAL
0 commit comments