Tell us what’s happening:
Can anyone please correct me? this code gives the same output
Your code so far
function rangeOfNumbers(startNum, endNum) {
if (startNum > endNum) {
return [];
} else {
let x =[];
x.push(startNum);
document.write(x);
rangeOfNumbers(startNum + 1, endNum);
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Use Recursion to Create a Range of Numbers
Link to the challenge: