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)

demo


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -