I'm trying to console log the sum of all the numbers from 1 to 10 (as see in my console.log and me calling the functions) but I'm just stumped.
In my first function I made it so the array would fill up and print out everything in between whatever i set for start and end. I have no idea how to rework the sum function to make the console.log show me 55 (the sum of all the numbers between 1 and 10)
a = [];
var range = function(start, end) {
for (j=start;j<=end;j++) {
a.push(j);
}
return a;
}
var sum = function(array) {
var array = a;
}
console.log(sum(range(1, 10)));
Like I said, it's the sum function that's giving me trouble. I'm stumped how to make it work with in the context of this little program.