Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Last active February 28, 2018 15:37
Show Gist options
  • Save aleclarson/e07851ecda9fb132f7cbdf3cf98e1008 to your computer and use it in GitHub Desktop.
Save aleclarson/e07851ecda9fb132f7cbdf3cf98e1008 to your computer and use it in GitHub Desktop.
randomString.js
window.randomString = (function() {
var chars = 'abcdefghijklmnopqrstuvwxyz'
return function randomString(len) {
if (!len) len = 10
var str = ''
for (var i = 0; i < len; i++) {
str += chars[Math.floor(Math.random() * chars.length)]
}
return str
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment