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 b8c8e29

Browse files
committed
add reduce map filter
1 parent cb27f4c commit b8c8e29

File tree

3 files changed

+72
-41
lines changed

3 files changed

+72
-41
lines changed

Week2/homework/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>week2JS</title>
6+
<meta charset="utf-8" />
7+
8+
9+
</head>
10+
11+
<body>
12+
13+
14+
<script type="text/javascript" src="maartjes_work.js"></script>
15+
<script type="text/javascript" src="map_filter.js"></script>
16+
</body>
17+
18+
</html>

Week2/homework/maartjes_work.js

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
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

45-
const tasks = monday.concat(tuesday);
43+
const tasks = monday.concat(tuesday)
44+
let minutesToHours = tasks.filter(a => a.duration >= 120).map(h => h.duration / 60);
4645

47-
// Add your code here
46+
console.log(minutesToHours);
47+
48+
let perHour = minutesToHours.map(v => v * 23) // per hour 23 euro
49+
50+
console.log(perHour);
51+
52+
let total = perHour.reduce(function(a, b) {
53+
return a + b;
54+
55+
});
56+
total = total.toFixed(2); //rounding number
57+
console.log("Maartje totally will earn: " + total + " Euro");

Week2/homework/map_filter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
const numbers = [1, 2, 3, 4];
44

5-
// Add your code here
5+
6+
const newNumbers = numbers.filter(w => w % 2 !== 0).map(x => x * 2);
7+
8+
console.log('The doubled numbers are: ' + newNumbers);

0 commit comments

Comments
 (0)