Skip to content

Instantly share code, notes, and snippets.

@piouc
Last active February 15, 2017 10:23
Show Gist options
  • Save piouc/ce4b13e48843151e80a6 to your computer and use it in GitHub Desktop.
Save piouc/ce4b13e48843151e80a6 to your computer and use it in GitHub Desktop.
randomString
function randomAsciiStrings(length){
return [...Array(length)].map(() => String.fromCharCode(0x20 + Math.random() * 0x5F | 0)).join('')
}
function randomStrings(length, source = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'){
return [...Array(length)].map(() => source[Math.random() * source.length | 0]).join('')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment