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
pull request
  • Loading branch information
Nouransaeed committed Aug 14, 2019
commit 4c4690ddad1b0ae7aeed001e707be2068cb861f6
133 changes: 133 additions & 0 deletions Week2/homework/week2maartjes-work.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

'use strict';



const monday = [

{

name: 'Write a summary HTML/CSS',

duration: 180,

},

{

name: 'Some web development',

duration: 120,

},

{

name: 'Fix homework for class10',

duration: 20,

},

{

name: 'Talk to a lot of people',

duration: 200,

},

];



const tuesday = [

{

name: 'Keep writing summary',

duration: 240,

},

{

name: 'Some more web development',

duration: 180,

},

{

name: 'Staring out the window',

duration: 10,

},

{

name: 'Talk to a lot of people',

duration: 200,

},

{

name: 'Look at application assignments new students',

duration: 40,

},

];



const maartjesTasks = monday.concat(tuesday);

const maartjesHourlyRate = 20;



function computeEarnings(tasks, hourlyRate) {

const inHoursArr = tasks.map(task => task.duration / 60).filter(hours => hours <= 2);

const maartjesPayArr = inHoursArr.map(hours => hours * maartjesHourlyRate);

const totalPay = maartjesPayArr.reduce((sum, amount) => sum + amount);

const toEuro = totalPay.toFixed(2);

return toEuro;

}





const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);



//converting



console.log(`Martje has earned €${earnings}`);


module.exports = {

maartjesTasks,

maartjesHourlyRate,

computeEarnings,

};