Can you help me spot the issue in this code snippet?
function range(start, end){
var arrayRange = [];
for(i= start; i<=end; i++){
arrayRange.push(i)
}
return(arrayRange);
}
var r = range(1,10);
console.log(r);
function sumRange(sumArray){
var total = 0;
for(var i=0; i <= sumArray.length; i++){
total = total + sumArray[i];
}
return total;
}
var s=sumRange(r);
console.log(s);
This is what shows up in the console.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
NaN
I'm working on an exercise from Eloquent Javascript to grasp callback functions. My goal is to achieve this output:
console.log(sum(range(1,10)));
// 55