Created
January 12, 2016 16:57
-
-
Save aray12/598aca575c02df9e038b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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