Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Week2 #295

Closed
wants to merge 9 commits into from
Closed

Week2 #295

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
77 changes: 77 additions & 0 deletions ghufran/maartjes-work.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'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,
},
];
/* cSpell: disable */
const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;

function computeEarnings(tasks, hourlyRate) {
// turn mins to hours
const duration = tasks.map(task => task.duration / 60);
return { ...task, duration: hours };
};

// remove less than 2 hours
const filteredHour = duration.filter(elem => elem.duration >= 2);
// earnings for the duration less than 2 hours
return filteredHour.reduce((acc, elem) => {
acc += elem.duration * hourlyRate;
return acc;
}, 0);
}
console.log(computeEarnings(maartjesTasks, maartjesHourlyRate));

const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);

// set the decimal nrs to have only two values
const roundEuros = earnings.toFixed(2); // 373.33333333333337

// call the value of toFixed(2)
console.log(`Maartje has earned €${roundEuros}`); // Maartje has earned €373.33

module.exports = {
maartjesTasks,
maartjesHourlyRate,
computeEarnings,
};
/* cSpell: enable */
14 changes: 14 additions & 0 deletions ghufran/map-filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

function doubleOddNumbers(num) {
num = num.filter(n => n % 2 !== 0).map(number => number * 2);
return num;
}

const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers)); // [2, 6] the double of [1,3]

module.exports = {
myNumbers,
doubleOddNumbers,
};