|
1 | | -'use strict'; |
| 1 | +"use strict"; |
2 | 2 |
|
| 3 | +// 2.2 |
3 | 4 | const monday = [ |
4 | 5 | { |
5 | | - name: 'Write a summary HTML/CSS', |
| 6 | + name: "Write a summary HTML/CSS", |
6 | 7 | duration: 180 |
7 | 8 | }, |
8 | 9 | { |
9 | | - name: 'Some web development', |
| 10 | + name: "Some web development", |
10 | 11 | duration: 120 |
11 | 12 | }, |
12 | 13 | { |
13 | | - name: 'Fix homework for class10', |
| 14 | + name: "Fix homework for class10", |
14 | 15 | duration: 20 |
15 | 16 | }, |
16 | 17 | { |
17 | | - name: 'Talk to a lot of people', |
| 18 | + name: "Talk to a lot of people", |
18 | 19 | duration: 200 |
19 | 20 | } |
20 | 21 | ]; |
21 | 22 |
|
22 | 23 | const tuesday = [ |
23 | 24 | { |
24 | | - name: 'Keep writing summary', |
| 25 | + name: "Keep writing summary", |
25 | 26 | duration: 240 |
26 | 27 | }, |
27 | 28 | { |
28 | | - name: 'Some more web development', |
| 29 | + name: "Some more web development", |
29 | 30 | duration: 180 |
30 | 31 | }, |
31 | 32 | { |
32 | | - name: 'Staring out the window', |
| 33 | + name: "Staring out the window", |
33 | 34 | duration: 10 |
34 | 35 | }, |
35 | 36 | { |
36 | | - name: 'Talk to a lot of people', |
| 37 | + name: "Talk to a lot of people", |
37 | 38 | duration: 200 |
38 | 39 | }, |
39 | 40 | { |
40 | | - name: 'Look at application assignments new students', |
| 41 | + name: "Look at application assignments new students", |
41 | 42 | duration: 40 |
42 | 43 | } |
43 | 44 | ]; |
44 | 45 |
|
45 | 46 | const tasks = monday.concat(tuesday); |
46 | 47 |
|
47 | | -// Add your code here |
| 48 | +let durationOfTasks = tasks.map(Element => Element.duration); |
| 49 | + |
| 50 | + console.log(durationOfTasks); |
| 51 | + |
| 52 | +// Map the tasks to durations in hours. |
| 53 | +let durationInHours = durationOfTasks |
| 54 | + .map(element => element / 60) |
| 55 | + |
| 56 | + console.log(durationInHours); |
| 57 | + |
| 58 | +// Filter out everything that took less than two hours |
| 59 | + |
| 60 | +let lessThanTwoHours = durationInHours |
| 61 | + |
| 62 | +.filter(element => element >= 2) |
| 63 | +console.log(lessThanTwoHours); |
| 64 | + |
| 65 | +// Multiply the each duration by a per-hour rate for billing and sum it all up. |
| 66 | + |
| 67 | +let paymentPerHour = durationOfTasks |
| 68 | + .map(element => (element / 60) * 100) |
| 69 | + |
| 70 | +console.log(paymentPerHour); |
| 71 | + |
| 72 | +let totalPayment = paymentPerHour |
| 73 | + .reduce(function (a, b) { |
| 74 | + return a + b; |
| 75 | + |
| 76 | + }); |
| 77 | +console.log(`Total hours payment is: ${totalPayment}`); |
| 78 | + |
| 79 | +// Output a formatted Euro amount, rounded to Euro cents, e.g: € 12.34. |
| 80 | + |
| 81 | +let amountEUR = totalPayment.toFixed(2); |
| 82 | +console.log(`The total amount to Euro is: ${amountEUR} EUR.`); |
| 83 | + |
| 84 | + |
0 commit comments