MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / sum

Function sum

code/solutions/04_1_the_sum_of_a_range.js:12–18  ·  view source on GitHub ↗
(array)

Source from the content-addressed store, hash-verified

10}
11
12function sum(array) {
13 let total = 0;
14 for (let value of array) {
15 total += value;
16 }
17 return total;
18}
19
20console.log(range(1, 10))
21// → [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected