Tests not passing even though manual testing works - Recursion with Range of Numbers

I’ve manually inputed all test values and outputted using console.log yet the ‘Run the Tests’ button does not pass me. I’m very sure I’m outputting an array with the correct values. Is there something I’m doing wrong or is there a problem with FCC?

Here is my code which outputs the correct array values.

var arr = [], count = 0;

function rangeOfNumbers(startNum, endNum) {
  if (startNum <= endNum) {
    if (arr[count] === endNum) {
      return arr;
    return rangeOfNumbers(startNum + 1, endNum);
  } else {
    return "Input error: startNum is greater than endNum";


Your code contains global variables that are changed each time the function is run. This means that after each test completes, subsequent tests start with the previous value. To fix this, make sure your function doesn’t change any global variables, and declare/assign variables within the function if they need to be changed.


var myGlobal = [1];
function returnGlobal(arg) {
  return myGlobal;
} // unreliable - array gets longer each time the function is run

function returnLocal(arg) {
  var myLocal = [1];
  return myLocal;
} // reliable - always returns an array of length 2

Thanks for the reply! Unfortunately I experimented with declaring both count and arr variables inside the function. Since it’s recursive it just ends up resetting the values to 0 and an empty array respectively. One of the tests says that I’m not returning an array. This doesn’t make sense because I see an array in the console being returned. I also confirmed my return statement by changing return arr; to return “arr”. I saw it change in the console so I know that statement line is executing. Even with a global var arr = []; shouldn’t the console recognize that an array is being returned? I’m puzzled…