Skip to content

Instantly share code, notes, and snippets.

@maxterry
Last active December 6, 2019 21:13
Show Gist options
  • Save maxterry/6dbc937715644c5a56d42ce7992ed058 to your computer and use it in GitHub Desktop.
Save maxterry/6dbc937715644c5a56d42ce7992ed058 to your computer and use it in GitHub Desktop.
Is it "a" or "an"?
// 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