Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
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
104 changes: 54 additions & 50 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
'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 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 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) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
}
const durationInHours = maartjesTasks.map(inHours => inHours.duration / 60);
console.log(durationInHours);

// eslint-disable-next-line no-unused-vars
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
const moreThanTweHours = durationInHours.filter(tweHours => tweHours >= 2);
console.log(moreThanTweHours);

// add code to convert `earnings` to a string rounded to two decimals (euro cents)
const computeEarnings = moreThanTweHours
.map(manyPerHours => manyPerHours * maartjesHourlyRate)
.reduce((total, manyPerHours) => total + manyPerHours, 0);
console.log(computeEarnings);


const currencyFormatter = new Intl.NumberFormat('NL', { style: 'currency', currency: 'EUR' });

const formattedCosts = currencyFormatter.format(computeEarnings);
console.log("Maartje has earned " + formattedCosts);

console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);

// Do not change or remove anything below this line
module.exports = {
maartjesTasks,
maartjesHourlyRate,
computeEarnings
};
maartjesTasks,
maartjesHourlyRate,
computeEarnings
};
21 changes: 12 additions & 9 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
'use strict';

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

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

const doubleOddNumbers = myNumbers
.filter(odd => odd % 2 !== 0)
.map(odd => odd * 2);

console.log(doubleOddNumbers);




// Do not change or remove anything below this line
module.exports = {
myNumbers,
doubleOddNumbers
};
myNumbers,
doubleOddNumbers
};