Tell us what’s happening:
I’ve tried but i cannot reach to the solution, and when i see the solution i dont understand why is that solution true.
Your code so far
function rangeOfNumbers(startNum, endNum) {
if (endNum - startNum === 0) {
return [startNum];
} else {
var numbers = rangeOfNumbers(startNum, endNum - 1);
numbers.push(endNum);
return numbers;
}
}
console.log(rangeOfNumbers(2,7))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
.
Challenge: Use Recursion to Create a Range of Numbers
Link to the challenge: