Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 080c26f

Browse files
committed
Add homework week2
1 parent 625c863 commit 080c26f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Week2/homework/maartjes_work.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,18 @@ const tuesday = [
4343
];
4444

4545
const tasks = monday.concat(tuesday);
46+
// console.log(tasks);
47+
4648

4749
// Add your code here
50+
51+
const perHour = 20;
52+
const totalEarned = tasks.filter(twoHoursOrMore => twoHoursOrMore.duration >= 120).reduce((total, task) =>
53+
total + (task.duration / 60 * perHour), 0);
54+
55+
// way 2, here I started with map.
56+
// const perHour = 20;
57+
// const totalEarned = tasks.map(toHours => toHours.duration / 60).filter(twoHoursOrMore => twoHoursOrMore >= 2)
58+
// .reduce((total, task) => total + (task * perHour), 0);
59+
60+
console.log('Maartje should receive for the performed tasks' + ' ' + '€ ' + totalEarned.toFixed(2));

Week2/homework/map_filter.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
'use strict';
22

3-
const numbers = [1, 2, 3, 4];
3+
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // I added some more numbers for testing.
44

55
// Add your code here
6+
7+
8+
const doubledOddNumbers = numbers.filter(number => number % 2 !== 0).map(number => number * 2);
9+
10+
console.log(doubledOddNumbers);
11+

0 commit comments

Comments
 (0)