Basic JavaScript - Use Recursion to Create a Range of Numbers

Tell us what’s happening:
i’m facing difficulties with my code please tell me whats wrong

Your code so far

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

 console.log(rangeOfNumbers(1, 5));

here’s the link to the task:

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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

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?