Le compte à rebours (10) devrait revenir [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] compte à rebours (5) devrait revenir [5, 4, 3, 2, 1]
function countdown(n) {
if (n < 1) {
return [];
} else {
const arr = countdown(n - 1);
arr.unshift(n);
return arr;
}
return myArray;
}
console.log(countdown(-1));
Busy Batfish