Slide 13
Slide 13 text
Array#reduce
var a = [4, 8, 15, 16, 23, 42];
a.reduce(function(sum, el, i, arr) { return sum + el });
// => 108
a.reduce(function(sum, el) { return sum + el }, 9000);
// => 9108
• there’s also Array#reduceRight and it does exactly what you think
= Enumerable#inject in Ruby