Countdown with recursion question

It looks like this works and passes the test judging from the console output. But when running the tests it says otherwise. Any thoughts, thanks in advance:

function countdown(n){
  if(n < 1) {
    return [];
  } else {
    let countArray = Array.prototype;
    countdown(n - 1);
    return countArray;
console.log(countdown(5)); // [5, 4, 3, 2, 1]

now add a second call to the function, and see what is the returned value to that

In the future, please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.

The easiest way to create a topic for help with your own solution is to click the Ask for Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge url while still allowing you to ask any question about the challenge or your code.

Thank you.

1 Like