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
fixing branch issue
  • Loading branch information
jshortz committed Jul 4, 2019
commit 9a5a0637d038490552b3f359abad643cb0ab8207
29 changes: 24 additions & 5 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,36 @@ const tuesday = [
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 computeEarnings = (tasks, hourlyRate) => {
let totalMins = 0;
for (let i = 0; i < tasks.length; i++) {
if (tasks[i].duration >= 120) {
totalMins += tasks[i].duration;
}
}
const hours = totalMins / 60;
return hours * hourlyRate;
}; */

const computeEarnings = (tasks, hourlyRate) => {
const hours = tasks.filter(function(task) {
return task.duration >= 120;
});
const total = hours.map(function(time) {
return time.duration / 60;
});
function sumofArray(sum, num) {
return sum + num;
}
return total.reduce(sumofArray) * hourlyRate;
};

// 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 €${Math.round((earnings + 0.00001) * 100) / 100}`);

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