File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,18 +44,23 @@ const tuesday = [
4444
4545const maartjesTasks = monday . concat ( tuesday ) ;
4646const maartjesHourlyRate = 20 ;
47+ const reducer = ( accumulator , currentValue ) => accumulator + currentValue ;
4748
4849function computeEarnings ( tasks , hourlyRate ) {
49- // Replace this comment and the next line with your code
50- console . log ( tasks , hourlyRate ) ;
50+ const taskCost = tasks
51+ . map ( task => task . duration / 60 )
52+ . filter ( task => task > 2 )
53+ . map ( task => task * hourlyRate )
54+ . reduce ( reducer , 0 ) ;
55+ return taskCost . toFixed ( 2 ) ;
5156}
5257
5358// eslint-disable-next-line no-unused-vars
5459const earnings = computeEarnings ( maartjesTasks , maartjesHourlyRate ) ;
5560
5661// add code to convert `earnings` to a string rounded to two decimals (euro cents)
5762
58- console . log ( `Maartje has earned €${ 'replace this string with the earnings rounded to euro cents' } ` ) ;
63+ console . log ( `Maartje has earned €${ earnings } ` ) ;
5964
6065// Do not change or remove anything below this line
6166module . exports = {
You can’t perform that action at this time.
0 commit comments