Skip to content

Instantly share code, notes, and snippets.

@antic183
Last active March 5, 2020 14:31
Show Gist options
  • Save antic183/851f792180eeacb92d81bf88b4b57e53 to your computer and use it in GitHub Desktop.
Save antic183/851f792180eeacb92d81bf88b4b57e53 to your computer and use it in GitHub Desktop.
generate random text with javascript
var text = "";
var alphabet = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u,v,w,x,y,z".split(",");
var wordCount = 256;
for(var i=0; i<wordCount; i++) {
var rand = null;
for (var x=0; x<7; x++) {
rand = Math.floor(Math.random() * alphabet.length);
text += alphabet[rand];
}
if (i<wordCount-1)
text += " ";
else
text += ".";
}
console.info("text length = " + text.length);
console.info(text);
@the1coder-pro
Copy link

Wow man this code is what i search about. Thank You !!!

@TriHydera
Copy link

great that what i needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment