Skip to content

Instantly share code, notes, and snippets.

@defims
Forked from reMekElek/annotated.js
Last active June 14, 2016 01:53
Show Gist options
  • Save defims/343f48d83a1c16317c25d4f0be061379 to your computer and use it in GitHub Desktop.
Save defims/343f48d83a1c16317c25d4f0be061379 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
}
export 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" ],
"version": "0.1.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment