-
Notifications
You must be signed in to change notification settings - Fork 29
/
17.goals.js
55 lines (51 loc) · 919 Bytes
/
17.goals.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
const goals = [
{
player: "Messi",
team: "Barcelona",
against: "Real Madrid",
score: "1-0",
minute: 90
},
{
player: "Iniesta",
team: "Barcelona",
against: "Real Madrid",
score: "2-1",
minute: 10
},
{
player: "Messi",
team: "Barcelona",
against: "Estudiantes",
score: "1-0",
minute: 88
},
{
player: "Tevez",
team: "Boca",
against: "River",
score: "3-2",
minute: 80
},
];
function getGoalsFrom(player) {
return goals.filter(g => g.player.toLowerCase() === player.toLowerCase());
}
function asyncTaskAndGetGoals(err, callback) {
setTimeout(() => {
if (err) {
callback(err, null);
return;
}
callback(null, goals);
}, 100);
}
function asyncPromiseAndGetGoals() {
return Promise.resolve(goals);
}
module.exports = {
goals,
getGoalsFrom,
asyncTaskAndGetGoals,
asyncPromiseAndGetGoals
};