Last active
December 6, 2019 21:13
-
-
Save maxterry/6dbc937715644c5a56d42ce7992ed058 to your computer and use it in GitHub Desktop.
Is it "a" or "an"?
This file contains 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
// Whether string starts with vowel sound | |
function isLeadingVowel(it) { | |
return ['a', 'e', 'i', 'o', 'u'].includes(it[0].toLowerCase()); | |
} | |
// "A" or "an" for given string | |
function getArticle(it) { | |
return isLeadingVowel(it) ? 'an' : 'a'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment