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

Mohammad-Darwesh homework js2 week2 #299

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ const tuesday = [
duration: 40,
},
];

/* cSpell:disable */
const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;

function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
tasks = tasks
.map(durations => durations.duration / 60)
.filter(durations => durations >= 2)
.map(durations => durations * hourlyRate)
.reduce((taskEarnings, taskEarning) => taskEarnings + taskEarning);
return tasks;
}

// eslint-disable-next-line no-unused-vars
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);

// add code to convert `earnings` to a string rounded to two decimals (euro cents)

console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);
// earnings.toFixed(2);
const formattedEarnings = Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'EUR',
}).format(earnings);
console.log(`Maartje has earned ${formattedEarnings}`);

// Do not change or remove anything below this line
module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
console.log(numbers);
numbers = numbers.filter(number => number % 2).map(number => number * 2);
return numbers;
}

const myNumbers = [1, 2, 3, 4];
Expand Down
Loading