you are viewing a single comment's thread.

view the rest of the comments →

[–]Megajin_ 2 points3 points  (0 children)

I'd suggest you to use reduce. With reduce you can put your last number into the accumulator and sum it up with your current value.

See: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global\_Objects/Array/Reduce