+ 8

Can we generate random 【ALPHABETS】with Math.random() method ?

Can we generate random ALPHABET not a string or group of ALPHABETS . Only a single ALPHABET out of 26. For example -: onclick(a,z) <script> document.write(Math.floor(Math.random()*(a,z))) </script> Is it possible have such function. || Note--:Only a individual(single) ALPHABET should generated. Not a string or Array ||

28th May 2018, 1:49 PM
OM KASHYAP
OM KASHYAP - avatar
4 Respuestas
+ 13
document.write(String.fromCharCode(Math.floor(65+Math.random()*100%26)))
28th May 2018, 2:52 PM
Hatsy Rei
Hatsy Rei - avatar
+ 7
Maybe with the switch loop you could assign a letter to a specific number.. so for example a = 1, b =2...
28th May 2018, 2:19 PM
Proff
Proff - avatar
28th May 2018, 5:42 PM
Louis
Louis - avatar
+ 4
Thanks everyone for your precious and wonderful help..
28th May 2018, 6:36 PM
OM KASHYAP
OM KASHYAP - avatar