Skip to content

Instantly share code, notes, and snippets.

@gleydson
Created March 30, 2020 16:49
Show Gist options
  • Save gleydson/9672d9f3801ee7af4d0d700adebf9ba2 to your computer and use it in GitHub Desktop.
Save gleydson/9672d9f3801ee7af4d0d700adebf9ba2 to your computer and use it in GitHub Desktop.
Function to create random characters
export default function random(length) {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i += 1) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment