Skip to content

Instantly share code, notes, and snippets.

@parkerproject
Forked from Dreyer/random-string.js
Created February 24, 2014 20:35
Show Gist options
  • Save parkerproject/9196488 to your computer and use it in GitHub Desktop.
Save parkerproject/9196488 to your computer and use it in GitHub Desktop.
// @source: http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
function randomStr(m) {
var m = m || 9; s = '', r = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i=0; i < m; i++) { s += r.charAt(Math.floor(Math.random()*r.length)); }
return s;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment