I don't understand it. (recursion)

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:

I think reading this post might be of help to understand it better. Confusion over Recursion (Last question of basic javascript)

Hey @kenosyt247,

Maybe you would like to study recursion a little deeper.

The links above are a good place to start with understanding recursion, but is there some specific part of this challenge that you are stuck on? If we know which bit trips you up, it’s much easier to help.