Can't pass the tests with the correct array

Tell us what’s happening:

Could someone please tell me why the code doesn’t pass test cases? I don’t have problems putting in the “right” solution to pass the tests, but this code returns the right array, as it seems, but still doesn’t pass the tests.

The task is: Basic JavaScript: Use Recursion to Create a Range of Numbers

Thank you for your help!

Your code so far

function rangeOfNumbers(startNum, endNum) {
array = typeof(array) == 'undefined' ? [] : array;
if (startNum == endNum) {
  return array;
} else {
  return rangeOfNumbers(startNum +1, endNum);


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0.

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

you need to define all your variables.

you never define array

1 Like

@lookingafar Also, make sure not to use a global variable for array.

1 Like