Skip to content

Instantly share code, notes, and snippets.

@capJavert
Created September 9, 2019 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capJavert/936042915fdc6ad07b526b611d65208f to your computer and use it in GitHub Desktop.
Save capJavert/936042915fdc6ad07b526b611d65208f to your computer and use it in GitHub Desktop.
Generate random string of specified length.
const randomString = (length = 16) => {
let string = ''
for (let i = 0; i < length; i += 1) {
const random = (Math.random() * 16) | 0 // eslint-disable-line
string += random.toString(16)
}
return string
}
export default randomString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment