1
+ 'use strict' ;
2
+
3
+ const monday = [ {
4
+ name : 'Write a summary HTML/CSS' ,
5
+ duration : 180
6
+ } ,
7
+ {
8
+ name : 'Some web development' ,
9
+ duration : 120
10
+ } ,
11
+ {
12
+ name : 'Fix homework for class10' ,
13
+ duration : 20
14
+ } ,
15
+ {
16
+ name : 'Talk to a lot of people' ,
17
+ duration : 200
18
+ }
19
+ ] ;
20
+
21
+ const tuesday = [ {
22
+ name : 'Keep writing summary' ,
23
+ duration : 240
24
+ } ,
25
+ {
26
+ name : 'Some more web development' ,
27
+ duration : 180
28
+ } ,
29
+ {
30
+ name : 'Staring out the window' ,
31
+ duration : 10
32
+ } ,
33
+ {
34
+ name : 'Talk to a lot of people' ,
35
+ duration : 200
36
+ } ,
37
+ {
38
+ name : 'Look at application assignments new students' ,
39
+ duration : 40
40
+ }
41
+ ] ;
42
+
43
+ const maartjesTasks = monday . concat ( tuesday ) ;
44
+ const maartjesHourlyRate = 20 ;
45
+
46
+ // Map the tasks to durations in hours.
47
+ const tasksInHour = maartjesTasks . map ( tasks => tasks . duration / 60 ) ;
48
+
49
+ // Filter out everything that took less than two hours
50
+ const longTasks = tasksInHour . filter ( task => {
51
+ return task >= 2 ;
52
+ } ) ;
53
+
54
+ // Multiply the each duration by a per-hour rate for billing (use €20/hour) and sum it all up
55
+ const profits = longTasks . map ( task => {
56
+ return task * 20 ;
57
+ } ) ;
58
+
59
+ let totalProfit = 0 ;
60
+ profits . forEach ( function ( profit ) {
61
+ totalProfit += profit ;
62
+ } ) ;
63
+
64
+ // Output a formatted Euro amount, rounded to Euro cents, e.g: €11.34
65
+ const roundedTotalProfit = totalProfit . toFixed ( 2 ) ;
66
+
67
+ // add code to convert `earnings` to a string rounded to two decimals (euro cents)
68
+ console . log ( `Maartje has earned €${ roundedTotalProfit } ` ) ;
0 commit comments