-
-
Save parzibyte/f12df39ae8403067ed3b1e8f746d6ed9 to your computer and use it in GitHub Desktop.
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
const cadenaAleatoria = longitud => { | |
// Nota: no uses esta función para cosas criptográficamente seguras. | |
const banco = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
let aleatoria = ""; | |
for (let i = 0; i < longitud; i++) { | |
// Lee más sobre la elección del índice aleatorio en: | |
// https://parzibyte.me/blog/2021/11/30/elemento-aleatorio-arreglo-javascript/ | |
aleatoria += banco.charAt(Math.floor(Math.random() * banco.length)); | |
} | |
return aleatoria; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment