What am I missing in JavaScript?

I am just started to learn JS on Freecode and doing that task Use Recursion to Create a Range of Numbers).
The function should return an array of integers which begins with a number represented by the startNum parameter and ends with a number represented by the endNum parameter. The starting number will always be less than or equal to the ending number. Your function must use recursion by calling itself and not use loops of any kind. It should also work for cases where both startNum and endNum are the same.

My solution is on below

let myVal = [];
function rangeOfNumbers(startNum, endNum) {
  if (startNum <= endNum) {
    myVal.push(startNum);
    startNum++;
    rangeOfNumbers(startNum, endNum);
  }

  return myVal;
}

rangeOfNumbers(2, 5);

Normally it should work well but I do not know why it is not acceptable.