Skip to content

Instantly share code, notes, and snippets.

@reMekElek
Forked from 140bytes/LICENSE.txt
Created August 14, 2011 09:07
Show Gist options
  • Save reMekElek/1144725 to your computer and use it in GitHub Desktop.
Save reMekElek/1144725 to your computer and use it in GitHub Desktop.
140byt.es -- Click ↑↑ fork ↑↑ to play!
function(
a, // {Number}: random string length
b, // : internal variable: result
c // : internal variable: char code
){
for (
b = ''; // result
a--; // random string length (arguments[0])
)
b += String.fromCharCode(( // http://www.w3schools.com/jsref/jsref_fromcharcode.asp
( c = 0|Math.random() * 52 ) // random value = random * [a-zA-Z]
< 26 ? 65 : 71 ) + c // < 26 ? [A-Z] : [a-z]) + random value
);
return b // result
}
function(a,b,c){for(b='';a--;)b+=String.fromCharCode(((c=0|Math.random()*52)<26?65:71)+c);return b}
{
"name": "getRandomString",
"description": "Generate random alpha [a-zA-Z] string.",
"keywords": [
"random",
"string"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment