Basic JavaScript: Use Recursion to Create a Range of Numbers. This is hard and I'm stuck

Help me:
i just follow how to create recursion from the last lesson, and change it a bit and i now i dont know why it didnt work.

My code so far


function rangeOfNumbers(startNum, endNum) {
    if (startNum >= endNum) {
        return [];
    } else {
        const array = rangeOfNumbers(startNum - 1);
        array.push(startNum);
        return array;
    }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers

Your if statement checks if startNum is greater or equal to endNum. If you call rangeOfNumbers with startNum equal to 1 and endNum equal to 5, when do you think startNum will ever be greater or equal to endNum?

ohh so, is it different like other loop methods? all i though was it just like looping and increasing the parameter when i set the if statement lol. so how to fix the statement?

First of all, the function takes two arguments and not just one argument.

Your current logic was decreasing startNum by 1 each time, so startNum was never going to be greater or equal to endNum.

You need to think about what your base case needs to be and then create a recursive call along with making sure you pass the applicable startNum and endNum values so that the base case is finally met.