This question already has an answer here:
- Generate random string/characters in JavaScript 65 answers
- Create GUID / UUID in JavaScript? 52 answers
- Random alpha-numeric string in JavaScript? [duplicate] 17 answers
i am trying to create a program which puts random numbers/letters in a textbox using javascript (in the browser console). I have tried my best to do it but i just couldn't do it.
my best attempt was:
var key = ((nums[Math.floor(Math.random() * nums.length)].toString()) + (Math.floor((Math.random() * 10)).toString()) + (Math.floor((Math.random() * 10)).toString()));
var key2 = ((Math.floor((Math.random() * 10)).toString()) + (Math.floor((Math.random() * 10)).toString()) + (Math.floor((Math.random() * 10)).toString()));
var key3 = ((Math.floor((Math.random() * 10)).toString()) + (Math.floor((Math.random() * 10)).toString()) + (Math.floor((Math.random() * 10)).toString()) + (Math.floor((Math.random() * 10)).toString()));
But unfortunately it only generates numbers. Does anyone know how to randomize both? Would appreciate if anyone could help me .
Regards, 3hr3nw3rt
Aucun commentaire:
Enregistrer un commentaire