Recursion to create a range of numbers

Tell us what’s happening:

  **Your code so far**

function rangeOfNumbers(startNum, endNum) {
const  arr=[];

arr.push(startNum);

if(startNum==endNum)
return arr;

return 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/89.0.4389.114 Safari/537.36.

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

1 Like

Please tell errors in my code and why it is not executing

it is executing, but have you checked what’s the output?
like, try console.log(rangeOfNumbers(3,6)), what does it return?

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