diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js index fc8c0e633..1c33a8bca 100644 --- a/Week2/homework/maartjes-work.js +++ b/Week2/homework/maartjes-work.js @@ -45,17 +45,33 @@ const tuesday = [ const maartjesTasks = monday.concat(tuesday); const maartjesHourlyRate = 20; +function computeTasksInHours(maartjesTasksX, celling) { + const marrtjeTasksInHours = maartjesTasksX + .map(task => task.duration / 60) + .filter(task => task >= celling); + return marrtjeTasksInHours; +} + function computeEarnings(tasks, hourlyRate) { // Replace this comment and the next line with your code - console.log(tasks, hourlyRate); + const Taskhours = computeTasksInHours(tasks, 2); + let rate = 0; + for (const task of Taskhours) { + const Total = task * hourlyRate; + rate += Total; + } + return rate; + // eslint-disable-next-line no-unused-vars } -// eslint-disable-next-line no-unused-vars const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); +const result = earnings.toFixed(2); + +// Math.round(rate * 100) / 100; // 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'}`); +console.log('Maartje has earned €' + result + '.'); // Do not change or remove anything below this line module.exports = { diff --git a/Week2/homework/map-filter.js b/Week2/homework/map-filter.js index ab3c622d4..ba6e1c30f 100644 --- a/Week2/homework/map-filter.js +++ b/Week2/homework/map-filter.js @@ -2,11 +2,12 @@ function doubleOddNumbers(numbers) { // Replace this comment and the next line with your code - console.log(numbers); + const newNumber = numbers.filter(number => (number % 2 === 1 ? number : false)).map(x => x + x); + return newNumber; } const myNumbers = [1, 2, 3, 4]; -console.log(doubleOddNumbers(myNumbers)); +console.log('Using the filter method :' + doubleOddNumbers(myNumbers)); // Do not change or remove anything below this line module.exports = {