Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Prev Previous commit
Next Next commit
homework week 3 exercise 1-2.
exercise 1-2 completed. It looks like i forgot to send the PR  on wendesday :-/
  • Loading branch information
whiteststar authored May 11, 2019
commit cf19db65ffd752fdbbb5fab217defd594d695163
83 changes: 73 additions & 10 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,78 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
console.log(numbers);
}
// exercise 1, double odd numbers

const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));

// Do not change or remove anything below this line
module.exports = {
myNumbers,
doubleOddNumbers,
};
const oddNumbers = myNumbers.filter(n => n % 2 !==0);

const newNumbers = oddNumbers.map(x => x * 2);

console.log(newNumbers); // => [2, 6]


//exercise 2

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: 1.0
}
];

const tuesday = [
{
name: 'Keep writing summary',
duration: 1.0
},
{
name: 'Some more web development',
duration: 180
},
{
name: 'Staring out the window',
duration: 10
},
{
name: 'Talk to a lot of people',
duration: 1.0
},
{
name: 'Look at application assignments new students',
duration: 40
}
];

const allTasks = monday.concat(tuesday);

const MaartjesHourlyPayment = 20;

function salary(tasks, hourlyPayment) {

const taskDuration = tasks.map(x =>x.duration);
const payableHours = taskDuration.filter(y => y > 119); //exclude less then 2 hours. No special codding added for 1.0 hours format, because there are no 2.0 hours:)
const total = (accumulator, currentValue) => accumulator + currentValue;
const totalInHours = payableHours.reduce(total);
const paymentRaw = totalInHours/60*20;
var payment = paymentRaw.toFixed(2);
return payment;
}

const earned = salary(allTasks, MaartjesHourlyPayment);

console.log(`Maartje has made €${earned}. Good Job.`);