Recursion to Create a Countdown problem

Tell us what’s happening:
I’m passing all the tests except for “You should use recursion to solve this problem.”

Your code so far

//Only change code below this line
function countdown(n){
return n > 0 ? [n].concat(countdown(n - 1)) : [];
console.log(countdown(5)); // [5, 4, 3, 2, 1]

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

I don’t think the exercise recognizes the recursion being called from the ternary operator. You might try using an actual if, then and see if it fixes the issue.

1 Like

The issue was actually a bug in the test. It was expecting to see a semi-colon immediately after the function call. I have submitted a pull request to correct the test.