Im trying to generate 5 characters from range (0-9 and a-Z). Is my solution optimal or did I overthink it a little? Would hardcoding a character list be more optimal?
const numbers=[
...Math.random()
.toString(36)
.substr(2, 5),
].map(element => (Math.random() > 0.5 ? element : element.toUpperCase())).join('');
Aucun commentaire:
Enregistrer un commentaire