Created
July 7, 2023 15:58
-
-
Save kyle-west/df85881408bfd112178932e446e72f9c to your computer and use it in GitHub Desktop.
Generate a random letter between range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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