Basic JavaScript: Use Recursion to Create a Countdown help, no solution found in the guide and in the forum

Tell us what’s happening:
How do I solve this challange, I have no idea on how to…

Your code so far


//Only change code below this line
function countdown(myArray, n){
if((n <= 0)){
  return [];
} else {
  countdown(myArray, n - 1);
  myArray.splice(myArray.length - (n - 1), 0, n);
  return myArray;
}
}

console.log(countdown([1, 5])); // [5, 4, 3, 2, 1]

Your browser information:

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

Challenge: Use Recursion to Create a Countdown

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

Hey @Ahmet_Popaj you may want to reset the challenge.

The last line is not correct. It is expecting/testing for:

console.log(countdown(5)); // [5, 4, 3, 2, 1]

first, try doing something with the value returned from this

try looking at your code with this tool, see if it helps you:
http://www.pythontutor.com/javascript.html

This challenge was updated very recently (last 12 hours), so you need to make sure you are using the correct function definition. There should only be a single parameter (n) defined for the function. I suggest clicking on Reset All Code and start again.

The initial challenge code should look like below:

//Only change code below this line
function countdown(n){
  return;
}
console.log(countdown(5)); // [5, 4, 3, 2, 1]