Skip to content

Commit c37cab3

Browse files
committed
Completed maartjes-work homework
1 parent 95935ac commit c37cab3

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Week2/homework/maartjes-work.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,23 @@ const tuesday = [
4444

4545
const maartjesTasks = monday.concat(tuesday);
4646
const maartjesHourlyRate = 20;
47+
const reducer = (accumulator, currentValue) => accumulator + currentValue;
4748

4849
function 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
5459
const 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
6166
module.exports = {

0 commit comments

Comments
 (0)