Where does the push method add the item to the array? The beginning or the end? Based on that answer, where would the value in endNum be placed in myArray for the following:
myArray.push(endNum);
So let’s say we called the function as:
rangeOfNumbers(1, 5)
The first time through we will hit the else block and make the following recursive call:
const myArray = rangeOfNumbers(1, 4)
The return value for the recursive call rangeOfNumbers(1, 4) will be an array and will be stored in myArray. Then we do the next line:
myArray.push(5)
So where is 5 added to myArray?
Does that help you see why the result is [1, 2, 3, 4, 5] instead of the other way around?