Basic JavaScript - Use Recursion to Create a Range of Numbers | Doesn't accept working solution

I appeared to be stuck on this challenge, so I created a local web page on my computer with VS Code to more easily debug what’s happening outside of freeCodeCamp. To my surprise, it returns exactly what it should, but freeCodeCamp doesn’t accept my solution! I think it’s because it expects me to subtract 1 from endNum but adding 1 to startNum appears to be a working solution although freeCodeCamp does not accept that solution.

This is the code I wrote locally on my computer in VS Code:

function rangeOfNumbers(startNum, endNum) {
    const arr = [];
    arr.push(startNum);
    
    if(startNum == endNum) {
        return arr;
    }

    arr.push(rangeOfNumbers(startNum + 1, endNum));
    return arr;
}

alert(rangeOfNumbers(1, 10));

If I link this to a blank html document, it alerts the correct numbers in the correct order. But freeCodeCamp does not accept this solution! Is this a bug? Note that I do not use alert in the actual freeCodeCamp solution. Only in VS Code. I also get the correct numbers in the correct order if I change the arguments from 1 and 10 respectively.

Link to the challenge:

Won’t this make an array inside of an array inside of an array…

You need to make a flat array

I’m also not sure if alert will work in the fCC editor.

I just wrote that I don’t use alert in fCC editor, only in VS Code…
You appear to be correct that it is creating nested arrays. Alert didn’t show this, but if I use console.log I can see that’s what’s happening. Thank you for your help!

I missed the part where you said you posed code you weren’t trying to get to pass in the fCC editor - hopefully my confusion is understandable, its somewhat early here.

I think that might be why I am rejected too. Lovely array but I guess it is one inside in a way but still…

If you have a question about a specific challenge as it relates to your written code for that challenge, and you’ve tried to solve it at least 3 times so far and still need some help, just click the Ask for Help button located on the challenge (it looks like a question mark).
This button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.