← Back to challenges

Recursion: Array Summation

JavaScriptHardrecursionarrays

Instructions

Create a function that sums up all the elements in the array recursively. The use of the array's built-in reduce() function is not allowed, thus, the approach is recursive.

Examples

recurAdd([1, 2, 3, 4, 10, 11]) ➞ 31

recurAdd([-3, 4, 11, 10, 21, 32, -9]) ➞ 66

recurAdd([-21, -7, 19, 3, 4, -8]) ➞ -10

Notes

  • You're expected to solve this challenge using a recursive approach.
  • If you think recursion is fun, you can find a collection of those challenges here.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.