Skip to content

Commit 3fbcb86

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

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

+3-6
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)