forked from HackYourFuture/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek_2
More file actions
73 lines (63 loc) · 1.36 KB
/
Copy pathweek_2
File metadata and controls
73 lines (63 loc) · 1.36 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
1.1
function doubleOddNumbers(numbers) {
console.log(numbers);
return numbers.filter(num => num % 2 !== 0).map(num => num * 2);
}
const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));
1.2
const monday = [
{
name: "Write a summary HTML/CSS",
duration: 180
},
{
name: "Some web development",
duration: 120
},
{
name: "Fix homework for class10",
duration: 20
},
{
name: "Talk to a lot of people",
duration: 200
}
];
const tuesday = [
{
name: "Keep writing summary",
duration: 240
},
{
name: "Some more web development",
duration: 180
},
{
name: "Staring out the window",
duration: 10
},
{
name: "Talk to a lot of people",
duration: 200
},
{
name: "Look at application assignments new students",
duration: 40
}
];
const tasks = [...monday, ...tuesday];
const rate = 20;
const tasksInHour = tasks
.map(i => i.duration / 60)
.filter(i => i >= 2)
.map(i => i * rate)
.reduce((total, value) => total + value)
.toFixed(2);
console.log(`€ ${tasksInHour}`);
// 60, 40, 66.66666, 80, 60, 66.6666
// total , value , result
// iteration 0 ... total = 60, value = 40 ---> 100
// iteration 1 ... total = 100, value = 66.66 --> 166.666
// iteration 2 ... total = 166.666, value = 80 --> 246.666
// iteration n .. total = something number