MCPcopy Create free account
hub / github.com/appacademy/Module-1-Resources / sumArrayWDefault

Function sumArrayWDefault

w3/d2/sum-array.js:43–50  ·  view source on GitHub ↗
(arr, sum = 0)

Source from the content-addressed store, hash-verified

41
42
43function sumArrayWDefault(arr, sum = 0) {
44 if(!arr.length) return sum;
45
46 let shifted = arr.shift();
47 sum += shifted;
48
49 return sumArrayWDefault(arr, sum);
50}
51
52/*
53sumArrayWDefault([], 6) => 6

Callers 1

sum-array.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected