Tell us what’s happening:
Your code so far
// Only change code below this line
var array=[];
function countdown(n){
if(n<1) {return array;}
else {
array.push(n);
array=countdown(n-1);
return array;
}
}
// Only change code above this line
console.log(countdown(5)); // [5, 4, 3, 2, 1]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
.
Challenge: Use Recursion to Create a Countdown
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown