Skip to content

Instantly share code, notes, and snippets.

@kyle-west
Created July 7, 2023 15:58
Show Gist options
  • Save kyle-west/df85881408bfd112178932e446e72f9c to your computer and use it in GitHub Desktop.
Save kyle-west/df85881408bfd112178932e446e72f9c to your computer and use it in GitHub Desktop.
Generate a random letter between range
const randLetter = (start = "A", end = "Z") => String.fromCharCode(
Math.floor(Math.random() * (end.charCodeAt(0) - start.charCodeAt(0) + 1)) + start.charCodeAt(0)
)
randLetter() // "F"
randLetter('a', 'd') // "d"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment