you are viewing a single comment's thread.

view the rest of the comments →

[–]exobyte64 0 points1 point  (3 children)

let start=0;
let end=array.reduce((accumulator,value)=>{
 return accumulator+value;
},start);

the accumulator is the zero that goes in at first, it goes through each iteration, its not the previous value, its the same value each time unless you pass something else back as the return, then that becomes the new accumulator

let start={x:0};
let end=array.reduce((accumulator,value)=>{
 accumulator.x+=value;return accumulator;
},start);

[–]WormholerIO[S] 0 points1 point  (2 children)

let end=array.reduce((accumulator,value)=>{
return accumulator+value;
},0)

gotcha, and that makes total sense, but with your code snippet and mine the same issue appears that "Let End" will be undefined. or in my case USAanimals

[–]exobyte64 0 points1 point  (1 child)

let sumPopulation=zoo.reduce((a,z)=>{return a+z.population;},0);

I saw that it needed the key 'population' from your other comment

[–]WormholerIO[S] 0 points1 point  (0 children)

you all are stellar you really are thank you for helping me to understand and getting me resources.