Skip to content

Instantly share code, notes, and snippets.

@saman-ghm
Created October 21, 2019 20:51
Show Gist options
  • Save saman-ghm/5620fbc13384b8c52806e1456d98b31c to your computer and use it in GitHub Desktop.
Save saman-ghm/5620fbc13384b8c52806e1456d98b31c to your computer and use it in GitHub Desktop.
export const random = (length: number): string => {
let result = "";
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment