i have been trying to solve the exercise on sum all numbers in a range and i am facing some issues.
This is my code so far. it returns the right value but does not validate the exercise.
I like some help on how to solve this problem
var sumArr = [];
function sumAll(arr) {
var maxVal = Math.max(arr[0], arr[1]);
var minVal = Math.min(arr[0], arr[1]);
while(minVal <= maxVal){
sumArr.push(minVal++);
}
var sumTotal = sumArr.reduce(function(sum, value){
return (sum + value);
}, 0);
return (sumTotal);
}
sumAll([10, 5]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/sum-all-numbers-in-a-range