Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Completed maartjes-work homework
  • Loading branch information
Catsudemo committed Jun 19, 2019
commit c37cab3ff3852d691457caac8af6c02396aebdea
11 changes: 8 additions & 3 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ const tuesday = [

const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;
const reducer = (accumulator, currentValue) => accumulator + currentValue;

function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
const taskCost = tasks
.map(task => task.duration / 60)
.filter(task => task > 2)
.map(task => task * hourlyRate)
.reduce(reducer, 0);
return taskCost.toFixed(2);
}

// 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'}`);
console.log(`Maartje has earned €${earnings}`);

// Do not change or remove anything below this line
module.exports = {
Expand Down