Skip to content
Open
Show file tree
Hide file tree
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
Next Next commit
completed task nr. 2
  • Loading branch information
chichiglacierz committed Aug 9, 2019
commit eb47824fd579ca63c3e522bffa90ec9782a50b9a
Binary file added .DS_Store
Binary file not shown.
Binary file added Week1/.DS_Store
Binary file not shown.
Binary file added Week2/.DS_Store
Binary file not shown.
14 changes: 11 additions & 3 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,25 @@ const tuesday = [
const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;

/**
* Use of High order functions: map, filter, toFixed
*/

function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
// mapping duration of tasks from minutes to hours and filtering out duties < 2h
const timeInHours = tasks.map(time => time.duration / 60).filter(duty => duty >= 2);
const salaryPerDay = timeInHours.map(hoursPerDay => hoursPerDay * hourlyRate);
const totalSalary = salaryPerDay.reduce((sum, dailySalary) => sum + dailySalary, 0);
const euroSalary = totalSalary.toFixed(2);
return euroSalary;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clear code 👍

}

// 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
8 changes: 6 additions & 2 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
// the following iterates the variables in numbers(with filter) and checking if they´re divisible by 2
// const newNumbers = [];
// for (let i = 0; i =numbers.length)
numbers = numbers.filter(num => num % 2 === 1).map(num => num * 2);
console.log(numbers);
return numbers;
}

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

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