|
| 1 | +'use strict'; |
| 2 | + |
| 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 | + }, |
| 20 | +]; |
| 21 | + |
| 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 | + }, |
| 43 | +]; |
| 44 | + |
| 45 | +const maartjesTasks = monday.concat(tuesday); |
| 46 | +const maartjesHourlyRate = 20; |
| 47 | +const reducer = (accumulator, currentValue) => accumulator + currentValue; |
| 48 | + |
| 49 | +function computeEarnings(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); |
| 56 | +} |
| 57 | + |
| 58 | +const taskCost = computeEarnings(maartjesTasks, maartjesHourlyRate); |
| 59 | + |
| 60 | +// eslint-disable-next-line no-unused-vars |
| 61 | + |
| 62 | +// add code to convert `earnings` to a string rounded to two decimals (euro cents) |
| 63 | + |
| 64 | +console.log(`Maartje has earned ${taskCost} euros`); |
| 65 | + |
| 66 | +// Do not change or remove anything below this line |
| 67 | +module.exports = { |
| 68 | + maartjesTasks, |
| 69 | + maartjesHourlyRate, |
| 70 | + computeEarnings, |
| 71 | +}; |
0 commit comments