Basic JavaScript - Use Recursion to Create a Countdown

Not sure what I am doing wrong.

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Use Recursion to Create a Countdown

Link to the challenge:

I would add a console log to see what countArray looks like when it is returned.

what you have there is what the example explained. That works for counting up. now you are writing a count down. So how would you reverse this function?

yes of course your right I needed the reverse order for count down. thanks! I figured it out.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.