11'use strict' ;
22
3- const monday = [
4- {
5- name : 'Write a summary HTML/CSS' ,
6- duration : 180
7- } ,
8- {
9- name : 'Some web development' ,
10- duration : 120
11- } ,
12- {
13- name : 'Fix homework for class10' ,
14- duration : 20
15- } ,
16- {
17- name : 'Talk to a lot of people' ,
18- duration : 200
19- }
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+ }
2019] ;
2120
22- const tuesday = [
23- {
24- name : 'Keep writing summary' ,
25- duration : 240
26- } ,
27- {
28- name : 'Some more web development' ,
29- duration : 180
30- } ,
31- {
32- name : 'Staring out the window' ,
33- duration : 10
34- } ,
35- {
36- name : 'Talk to a lot of people' ,
37- duration : 200
38- } ,
39- {
40- name : 'Look at application assignments new students' ,
41- duration : 40
42- }
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+ }
4341] ;
4442
4543const maartjesTasks = monday . concat ( tuesday ) ;
4644const maartjesHourlyRate = 20 ;
4745
48- function computeEarnings ( tasks , hourlyRate ) {
49- // Replace this comment and the next line with your code
50- console . log ( tasks , hourlyRate ) ;
51- }
46+ const durationInHours = maartjesTasks . map ( inHours => inHours . duration / 60 ) ;
47+ console . log ( durationInHours ) ;
5248
53- // eslint-disable-next-line no-unused-vars
54- const earnings = computeEarnings ( maartjesTasks , maartjesHourlyRate ) ;
49+ const moreThanTweHours = durationInHours . filter ( tweHours => tweHours >= 2 ) ;
50+ console . log ( moreThanTweHours ) ;
5551
56- // add code to convert `earnings` to a string rounded to two decimals (euro cents)
52+ const computeEarnings = moreThanTweHours
53+ . map ( manyPerHours => manyPerHours * maartjesHourlyRate )
54+ . reduce ( ( total , manyPerHours ) => total + manyPerHours , 0 ) ;
55+ console . log ( computeEarnings ) ;
56+
57+
58+ const currencyFormatter = new Intl . NumberFormat ( 'NL' , { style : 'currency' , currency : 'EUR' } ) ;
59+
60+ const formattedCosts = currencyFormatter . format ( computeEarnings ) ;
61+ console . log ( "Maartje has earned " + formattedCosts ) ;
5762
58- console . log ( `Maartje has earned €${ 'replace this string with the earnings rounded to euro cents' } ` ) ;
5963
6064// Do not change or remove anything below this line
6165module . exports = {
62- maartjesTasks,
63- maartjesHourlyRate,
64- computeEarnings
65- } ;
66+ maartjesTasks,
67+ maartjesHourlyRate,
68+ computeEarnings
69+ } ;
0 commit comments