Skip to content

Latest commit

 

History

History
8 lines (6 loc) · 186 Bytes

sum-of-array-of-numbers.md

File metadata and controls

8 lines (6 loc) · 186 Bytes

Sum of array of numbers

Use reduce() to add each value to an accumulator, initialized with a value of 0.

var sum = arr =>
  arr.reduce( (acc , val) => acc + val, 0);