Tell us what’s happening:
I didn’t too much understand about recursion, especially with this reduce one. I already watch some videos on youtube and read an article, but I’m still didn’t know why this won’t reduce.
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);
return arr;
}
}
console.log(countdown(10))
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
.
Challenge: Use Recursion to Create a Countdown
Link to the challenge: