What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-08-28 07:13:02
stackoverflow array reduce
const arr = [{x:1}, {x:2}, {x:4}]; arr.reduce(function (acc, obj) { return acc + obj.x; }, 0); //result = 7 // acc = accumulator (result from the last iteration) // obj = iterated object from arr // 0 = initial value for the accumulator(acc) // ... Add solution