Tell us what’s happening:
I was able to work through this problem only after finding out I was supposed to return [startNum] and not [endNum]…if we keep .push()ing endNums to the variable then why are we not returning the variable or [endNum]?
Your code so far
function rangeOfNumbers(startNum, endNum) {
if (endNum === startNum) {
return [startNum];
} else {
var numbers = rangeOfNumbers(startNum, endNum - 1);
numbers.push(endNum);
return numbers;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36.
Challenge: Use Recursion to Create a Range of Numbers