lundi 30 décembre 2019

How to get a random number/letter combination in Javascript? [duplicate]

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