Tell us what’s happening:
My solution is failing, I read this post My method was similar to solution 1 but I think I am missing some key concept here.
Your code so far
// Only change code below this line
function countdown(n){
if(n < 1)
return [];
return countdown(n-1).unshift(n);
}
// Only change code above this line
console.log(countdown(2));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36
.
Challenge: Use Recursion to Create a Countdown
Link to the challenge: