Basic JavaScript - Use Recursion to Create a Countdown

So my code isn’t passing, and I was wondering if someone can explain to me why in the easiest terms to understand. Thanks!

Your code so far

// Only change code below this line
function countdown(n){
return (n<1)?[]
:(n>1)?[n].concat(countdown(n-1));

}
// 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/108.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Use Recursion to Create a Countdown

Link to the challenge:

I figured it out!

function countdown(n){

return (n<1)?[]

:[n].concat(countdown(n-1));

}
1 Like

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