-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
142 lines (88 loc) · 4.14 KB
/
index.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { fifaData } from './fifa.js';
// ⚽️ M V P ⚽️ //
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 1: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Practice accessing data by console.log-ing the following pieces of data note, you may want to filter the data first 😉*/
//(a) Home Team name for 2014 world cup final
//(b) Away Team name for 2014 world cup final
//(c) Home Team goals for 2014 world cup final
//(d) Away Team goals for 2014 world cup final
//(e) Winner of 2014 world cup final */
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use getFinals to do the following:
1. Receive data as a parameter
2. Return an array of objects with the data of the teams that made it to the final stage
hint - you should be looking at the stage key inside of the objects
*/
function getFinals(/* code here */) {
/* code here */
}
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use the higher-order function called getYears to do the following:
1. Receive an array
2. Receive a callback function getFinals from task 2
3. Return an array called years containing all of the years in the getFinals data set*/
function getYears(/* code here */) {
/* code here */
}
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use the higher-order function getWinners to do the following:
1. Receives an array
2. Receives the callback function getFinals from task 2
3. Determines the winner (home or away) of each `finals` game.
4. Returns the names of all winning countries in an array called `winners` */
function getWinners(/* code here */) {
/* code here */
}
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use the higher-order function getWinnersByYear to do the following:
1. Receive an array
2. Receive a callback function getYears from task 3
3. Receive a callback function getWinners from task 4
4. Return an array of strings that say "In {year}, {country} won the world cup!"
hint: the strings returned need to exactly match the string in step 4.
*/
function getWinnersByYear(/* code here */) {
/* code here */
}
/* 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6: 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
Use the higher order function getAverageGoals to do the following:
1. Receive the callback function getFinals from task 2 ensure you pass in the data as an argument
2. Return the the average number of the total home team goals and away team goals scored per match and round to the second decimal place.
(Hint: use .reduce and do this in 2 steps)
Example of invocation: getAverageGoals(getFinals(fifaData));
*/
function getAverageGoals(/* code here */) {
/* code here */
}
/// 🥅 STRETCH 🥅 ///
/* 💪💪💪💪💪 Stretch 1: 💪💪💪💪💪
Create a function called `getCountryWins` that takes the parameters `data` and `team initials` and returns the number of world cup wins that country has had.
Hint: Investigate your data to find "team initials"!
Hint: use `.reduce` */
function getCountryWins(/* code here */) {
/* code here */
}
/* 💪💪💪💪💪 Stretch 2: 💪💪💪💪💪
Write a function called getGoals() that accepts a parameter `data` and returns the team with the most goals score per appearance (average goals for) in the World Cup finals */
function getGoals(/* code here */) {
/* code here */
}
/* 💪💪💪💪💪 Stretch 3: 💪💪💪💪💪
Write a function called badDefense() that accepts a parameter `data` and calculates the team with the most goals scored against them per appearance (average goals against) in the World Cup finals */
function badDefense(/* code here */) {
/* code here */
}
/* If you still have time, use the space below to work on any stretch goals of your chosing as listed in the README file. */
/* 🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑 */
function foo(){
console.log('its working');
return 'bar';
}
export default{
foo,
getFinals,
getYears,
getWinners,
getWinnersByYear,
getAverageGoals
}