1// Write a recursive method that returns the sum of all elements in an array
2
3function recSum(nums) {
4 if (nums.length === 1 ) {
5 return nums[0];
6 }
7 if (nums.length === 0 ) {
8 return 0;
9 }
10 let sum = nums[0] + recSum(nums.slice(1,nums.length));
11 return sum;
12}