Skip to content

Instantly share code, notes, and snippets.

@justincorrigible
Created November 9, 2017 16:31
Show Gist options
  • Save justincorrigible/a11f35e818c5a77a859657d47bae7265 to your computer and use it in GitHub Desktop.
Save justincorrigible/a11f35e818c5a77a859657d47bae7265 to your computer and use it in GitHub Desktop.
Generate a string filled with random characters. Takes a custom length and char options.
const generateRandomString = (length = 6, chars = '0123456789abcdefghijklmnOPQRSTUVWXYZ') =>
Array.apply(null, {length}).reduce(hash => hash.concat(chars[Math.round(Math.random() * (chars.length - 1))]), '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment