Use Recursion to Create a Countdown In a previous challenge, you learned how to use recursion to r code example
Example: recursion countdown javascript
function countdown(n){
if (n < 1) {
return [];
} else {
const arr = countdown(n - 1);
arr.unshift(n);
return arr;
}
}
console.log(countdown(5)); // [5, 4, 3, 2, 1]