Recursion: Array Summation

Published by Deep Xavier in

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.
  • You can read on more topics about recursion (see Resources tab) if you aren't familiar with it yet or haven't fully understood the concept behind it before taking up this challenge.
  • If you think recursion is fun, you can find a collection of those challenges here.
Watch a quick demo on how Edabit works.