Skip to content

sumSimple

sumSimple(x): number

Defined in: src/sum_simple.js:12

The simple sum of an array is the result of adding all numbers together, starting from zero.

This runs in O(n), linear time, with respect to the length of the array.

number[]

input

number

sum of all input numbers

sumSimple([1, 2, 3]); // => 6