Last active
February 14, 2023 12:56
-
-
Save dcortesnet/7797a3cb9967dacb5706da5515017e02 to your computer and use it in GitHub Desktop.
Javascript generar array cuenta regresiva con recursividad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countdown(n){ | |
if(n < 1){ | |
return [] | |
} | |
const countArray = countdown(n - 1); | |
countArray.unshift(n) | |
return countArray; | |
} | |
console.log(countdown(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment