Skip to content

Instantly share code, notes, and snippets.

@aray12
Created January 12, 2016 16:57
Show Gist options
  • Save aray12/598aca575c02df9e038b to your computer and use it in GitHub Desktop.
Save aray12/598aca575c02df9e038b to your computer and use it in GitHub Desktop.
const someArray = [4,3,3,2,5,6,63,1,43,34,46,46,2,35,35,64,75];
function sum(list) {
let count = 1;
function add(x,y) {
const sum = x + y;
if(++count > list.length - 1) {
return sum;
}
return add(sum, list[count]);
}
return add(list[0], list[1]);
}
const result = sum(someArray);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment