Skip to content
Prev Previous commit
Next Next commit
changed wesbos#5 to ES6 arrow function
  • Loading branch information
laryl.li committed Feb 17, 2020
commit 3fbcb863c0949d51807ade5324f79aed36daccca
9 changes: 3 additions & 6 deletions 04 - Array Cardio Day 1/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@

// Array.prototype.reduce()
// 4. How many years did all the inventors live all together?
const year = inventors.reduce(liveTogether, 0);

function liveTogether(totalYears, x){
return totalYears+ (x.passed - x.year);
}

const year = inventors.reduce((totalYears,x) => {
return totalYears + (x.passed - x.year);
}, 0);
console.log(year);

// 5. Sort the inventors by years lived
Expand Down