Last active
March 29, 2016 10:30
-
-
Save sophiabrandt/4d8e73271f7b8413f77d 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
function sumAll(arr) { | |
var min = Math.min.apply(null, arr), | |
max = Math.max.apply(null, arr), | |
newArr = [], | |
i; | |
for (i = min; i <= max; i++) { | |
newArr.push(i); | |
} | |
return newArr.reduce(function (a,b) { | |
return a+b; | |
}); | |
} | |
sumAll([10, 5]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment