Visitar URL original
changed #5 to ES6 arrow function · Laryl14/JavaScript30@3fbcb86 · GitHub
Skip to content

Commit 3fbcb86

Browse files
author
laryl.li
committed
changed wesbos#5 to ES6 arrow function
1 parent 11e19e8 commit 3fbcb86

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎04 - Array Cardio Day 1/index-START.html‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@
4646

4747
// Array.prototype.reduce()
4848
// 4. How many years did all the inventors live all together?
49-
const year = inventors.reduce(liveTogether, 0);
50-
51-
function liveTogether(totalYears, x){
52-
return totalYears+ (x.passed - x.year);
53-
}
54-
49+
const year = inventors.reduce((totalYears,x) => {
50+
return totalYears + (x.passed - x.year);
51+
}, 0);
5552
console.log(year);
5653

5754
// 5. Sort the inventors by years lived

0 commit comments

Comments
 (0)