Basic JavaScript - Use Recursion to Create a Countdown

My code is not passing, though i have seen a solution that uses unshift instead of push but i dont know why it was used

  **Your code so far**

// Only change code below this line
function countdown(n){
if(n<1){
  return [];
}else{
  const arr = countdown(n-1);
  arr.push(n);
  return arr;
}

}
// Only change code above this line
  **Your browser information:**

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

Challenge: Basic JavaScript - Use Recursion to Create a Countdown

Link to the challenge:

Did you try to log the output so you can compare the results with the expected one?

You copied/pasted the example code that will create an array with the numbers increasing by one? Why would you think the exact same code would put the numbers in descending order?

Some thing that are important to understand about recursion is that functions will return a value to where they where called, and there is a thing called the call stack. Read up on the call stack if you haven’t yet. Its why things can look like there going “in reverse” from what you expect them to be like with push or unshift. There are also many topics on these forums about recursion that go step by step explaining everything that is going on.

And there is a nice site that will let you put your code in and watch it run step by step. https://pythontutor.com/

Good luck, recursion can be annoying to understand