What is different for my program?

Tell us what’s happening:
i dont’t know what i am doing wrong. I’ve created an array, pushed the increasing number in the array and finally returned it with them.

  **Your code so far**

function rangeOfNumbers(startNum, endNum) {
  return [endNum];
  let a =[]
  return a;


//create arr
//if start===end, print [end]
//if start!=end
//return arr
  **Your browser information:**

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

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

Why are you redefining an empty array every time you call this function?

This function always returns an array. The key idea of recursion is to call the function with a reduced input and use the output of that function call.

1 Like

you are right! i did’nt notice it before. and here i am who spent 2 days on something which could’ve been solved in two minutes.

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