I've just started an exercise in Chapter 4 of a book called Eloquent JavaScript. The exercise asks me to do the following:
"Write a range function that takes two arguments, start and end, and returns an array containing all the numbers from start up to (and including) end."
However, when I write the following code:
function range(start, end) {
array = [];
for (var i = start; i <= end; i += 1) {
array.push(i);
}
return array;
}
console.log(range(5, 2));
It returns square brackets ( [] ). Does anyone know what the issue might be? Thanks a bunch!