Skip to content

Commit 52b1c75

Browse files
committed
Ex2
1 parent 508b343 commit 52b1c75

1 file changed

Lines changed: 42 additions & 16 deletions

File tree

‎Week2/js-exercises/ex2-whatsYourMondayWorth.js‎

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,51 @@
1414

1515
function dayWorth(tasks, hourlyRate) {
1616
// put your code in here, the function does returns a euro formatted string
17+
const amountMoney = tasks
18+
.map(number => number.duration / 60 * hourlyRate)
19+
.reduce((a, b) => a + b, 0);
20+
return `\u20AC${Math.round(amountMoney * 100) / 100}`;
1721
}
1822

1923
const mondayTasks = [{
20-
name: 'Daily standup',
21-
duration: 30, // specified in minutes
22-
},
23-
{
24-
name: 'Feature discussion',
25-
duration: 120,
26-
},
27-
{
28-
name: 'Development time',
29-
duration: 240,
30-
},
31-
{
32-
name: 'Talk to different members from the product team',
33-
duration: 60,
34-
},
24+
name: 'Daily standup',
25+
duration: 30, // specified in minutes
26+
},
27+
{
28+
name: 'Feature discussion',
29+
duration: 120,
30+
},
31+
{
32+
name: 'Development time',
33+
duration: 240,
34+
},
35+
{
36+
name: 'Talk to different members from the product team',
37+
duration: 60,
38+
},
3539
];
3640

3741
console.log(dayWorth(mondayTasks, 25))
38-
console.log(dayWorth(mondayTasks, 13.37))
42+
console.log(dayWorth(mondayTasks, 13.37))
43+
44+
//new test array
45+
const fridayTasks = [{
46+
name: 'a',
47+
duration: 40, // specified in minutes
48+
},
49+
{
50+
name: 'b',
51+
duration: 20,
52+
},
53+
{
54+
name: 'c',
55+
duration: 120,
56+
},
57+
{
58+
name: 'd',
59+
duration: 180,
60+
},
61+
];
62+
63+
console.log(dayWorth(fridayTasks, 15))
64+
console.log(dayWorth(fridayTasks, 8.21))

0 commit comments

Comments
 (0)