Simple example of array sum using recursion

Lucio Flores
2022-04-05T01:58:48Z

sumArrayRecursive.js

| function sumArrayRecursive(arr){
| if(arr.length == 1) return arr[0];
| else if(arr.length == 0) return 0;
| else{
| return arr[arr.length - 1] + sumArrayRecursive(arr.slice(0, arr.length - 1));
| }
| }