Recusion problem

Tell us what’s happening:

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 + 1);
  
  return arr
}

}
countdown (-1);
countdown (10);
countdown (5)
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 4.4.2; GT-I9301I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.


This is strange. Why the + 1?


Also, it is very confusing to read when you places spaces between your function name and ()s

  • Good: countdown(10)
  • Bad: countdown (10)