Remove the first line of your function sumOfRange() var numbers = [1,-1,1,-1,1]
because you are re-initializing the value of numbers, you need to use to array that is passed to the function when it is called.
function sumOfRange(numbers) {
var sum = 0;
for (var i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum;
}
console.log(sumOfRange([1,-1,1,-1,1]));
console.log(sumOfRange([1,2,3,4,5]));
console.log(sumOfRange([-4,-5,-10,0]));
0
solved Sum of range in array