-
-
Save reMekElek/1144725 to your computer and use it in GitHub Desktop.
140byt.es -- Click ↑↑ fork ↑↑ to play!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(a,b,c){for(b='';a--;)b+=String.fromCharCode(((c=0|Math.random()*52)<26?65:71)+c);return b} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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