Skip to content

Instantly share code, notes, and snippets.

@tolotrasmile
Last active March 5, 2024 15:30
Show Gist options
  • Save tolotrasmile/9fb521e83dd9f6a6267b3e617d03dfae to your computer and use it in GitHub Desktop.
Save tolotrasmile/9fb521e83dd9f6a6267b3e617d03dfae to your computer and use it in GitHub Desktop.
/**
* Generate random string with specified length
* Each generated letter will be from A to Z
*
* 65 = A
* 90 = Z
* A-Z = 25
*
* @param length
*/
function randomString(length: number): string {
return Array.from({ length }, () => String.fromCharCode(25 * Math.random() + 65)).join('')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment