Creationg a Range of Numbers

Tell us what’s happening:
Confused about what to do. Please help.

Your code so far


function rangeOfNumbers(startNum, endNum) {


return [];
};

rangeOfNumbers(1,5);
rangeOfNumbers(6,9);
rangeOfNumbers(4,4);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 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

Hi @dynamic_dreamer7,
This could be help:

but before looking at the solution below, you first understand the flowchart you find.

1 Like

An example of what your function should return is if you call the function with the arguments 1 and 5 respectively (like below):

rangeOfNumbers(1, 5);

then your function needs to return the following array:

[1, 2, 3, 4, 5]

That is what your function should do. The only other requirement is for the function to be recursive and not use any kind of loop syntax ( Your code should not use any loop syntax ( for or while or higher order functions such as forEach , map , filter , or reduce ).