Local variables would be better for caching arrays than global variables, but I’d like to know which is the global variable. And my function should return an array, but does rangeOfNumbers() provide an array?
Your code so far
function rangeOfNumbers(startNum, endNum) {
if (endNum - startNum === 0) {
return startNum;
} else {
let numbers = rangeOfNumbers(startNum, endNum - 1);
numbers.push(endNum);
}
return numbers;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Challenge Information:
Basic JavaScript - Use Recursion to Create a Range of Numbers