javascript - Need to generate randoms alphabets on each time page load -
i need generate random letter a-z multiple times on page when refresh or reload. may bit confused here whether can create array storing alphabets , use .random method of javascript . i'm pretty sure need use random here. there other simple way doing in jquery.
i don't think there's simpler way of doing jquery. you'll have use random
method generate desired text. try like:
function generaterandomtext(n) { var text = ''; (var = 0; < n; i++) { text += string.fromcharcode(65 + math.floor(math.random() * 26) + 32 * (math.round(math.random()))); } return text; }
the math.floor(math.random() * 26)
bit picks letter, , math.round(math.random())
gives random 0 or 1 value, decides case(upper , lower respectively)
Comments
Post a Comment