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
+ // eslint-disable-next-line no-unused-vars
45
+ const maartjesHourlyRate = 20 ;
46
+
47
+ // Map the tasks to durations in hours.
48
+ const tasksInHour = maartjesTasks . map ( tasks => tasks . duration / 60 ) ;
49
+
50
+ // Filter out everything that took less than two hours
51
+ const longTasks = tasksInHour . filter ( task => task >= 2 ) ;
52
+
53
+ // Multiply the each duration by a per-hour rate for billing (use €20/hour) and sum it all up
54
+ const profits = longTasks . map ( task => task * 20 ) ;
55
+
56
+ let totalProfit = 0 ;
57
+ profits . forEach ( function ( profit ) {
58
+ totalProfit += profit ;
59
+ } ) ;
60
+
61
+ // Output a formatted Euro amount, rounded to Euro cents, e.g: €11.34
62
+ const roundedTotalProfit = totalProfit . toFixed ( 2 ) ;
63
+
64
+ // add code to convert `earnings` to a string rounded to two decimals (euro cents)
65
+ console . log ( `Maartje has earned €${ roundedTotalProfit } ` ) ;
0 commit comments