I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
What is the return value of the push method? I think you are not understanding what it is and end up returning something unintended here.
Also, you have the following:
if (startNum <= endNum) {
return [];
If I call this function like rangeOfNumbers(1, 5). startNum will be 1 and endNum will be 5, so your function will just return an empty array. Why do you want to return an empty array when startNum is less than or equal to endNum?