-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
104 lines (56 loc) · 2.88 KB
/
index.js
File metadata and controls
104 lines (56 loc) · 2.88 KB
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
import { fifaData } from './fifa.js';
console.log(fifaData);
console.log('its working');
// ⚽️ M V P ⚽️ //
/* Task 1: Investigate the data above. Practice accessing data by console.log-ing the following pieces of data
(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: Create a function called getFinals that takes `data` as an argument and returns an array of objects with only finals data */
function getFinals(/* code here */) {
/* code here */
};
/* Task 3: Implement a higher-order function called `getYears` that accepts the callback function `getFinals`, and returns an array called `years` containing all of the years in the dataset */
function getYears(/* code here */) {
/* code here */
};
getYears();
/* Task 4: Implement a higher-order function called `getWinners`, that accepts the callback function `getFinals()` and determine the winner (home or away) of each `finals` game. Return the name of all winning countries in an array called `winners` */
function getWinners(/* code here */) {
/* code here */
};
getWinners();
/* Task 5: Implement a higher-order function called `getWinnersByYear` that accepts the following parameters and returns a set of strings "In {year}, {country} won the world cup!"
Parameters:
* callback function getWinners
* callback function getYears
*/
function getWinnersByYear(/* code here */) {
};
getWinnersByYear();
/* Task 6: Write a function called `getAverageGoals` that accepts a parameter `data` and returns the the average number of home team goals and away team goals scored per match (Hint: use .reduce and do this in 2 steps) */
function getAverageGoals(/* code here */) {
/* code here */
};
getAverageGoals();
/// 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 */
};
getCountryWins();
/* Stretch 3: 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 */
};
getGoals();
/* Stretch 4: 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 */
};
badDefense();
/* If you still have time, use the space below to work on any stretch goals of your chosing as listed in the README file. */