Tuesday, April 26, 2016

ES6 reduce function cheatsheet

[3,6,7,9,10].reduce((a,b,i,all) => {console.log(a + " " + b + " " + i + " " + all);return a+b;})

3 6 1 3,6,7,9,10
9 7 2 3,6,7,9,10
16 9 3 3,6,7,9,10
25 10 4 3,6,7,9,10
> 35

No comments: