Unable to unerstand recursion

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
  function rangeOfNumbers(startNum, endNum) {
return startNum <= -1 ? startNum.push : endNum >= -1 ? endNum.unshift : [];

}

console.log(rangeOfNumbers(1, 5));


function rangeOfNumbers(startNum, endNum) {
if(startNum <= 1){
 return = startNum.push (startNum-1) 
}else if (endNum <= 1){
  return endNum.unshift (endNum - 1)

  }else{
    return []
  }
  
};
console.log(rangeOfNumbers(1,5));

  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

Yes, recursion is very difficult when you are starting out. Heck, I’ve been doing this for a while and it still melts my brains sometimes. Cut yourself some slack.

There are a lot of discussions about recursion on the forum, especially recently for some strange reason. I’ve had two recent explanations, here and here. Take a look at those and other explanations in those threads and see if that helps. If not, come back and let us know what is still troubling you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.