Skip to content

Latest commit

 

History

History
12 lines (10 loc) · 191 Bytes

RecursiveSum.md

File metadata and controls

12 lines (10 loc) · 191 Bytes

Recursive Sum Solution

JavaScript

const recursiveSum = arr => {
  if (arr.length === 1) {
    return arr[0];
  }
  return arr[0] + recursiveSum(arr.slice(1, arr.length));
};