← Back to challenges

Vowel Families

JavaScriptHardobjectsstringssorting

Instructions

Write a function that selects all words that have all the same vowels (in any order and/or number) as the first word, including the first word.

Examples

sameVowelGroup(["toe", "ocelot", "maniac"]) ➞ ["toe", "ocelot"]

sameVowelGroup(["many", "carriage", "emit", "apricot", "animal"]) ➞ ["many"]

sameVowelGroup(["hoops", "chuff", "bot", "bottom"]) ➞ ["hoops", "bot", "bottom"]

Notes

  • Words will contain only lowercase letters, and may contain whitespaces.
  • Frequency does not matter (e.g. if the first word is "loopy", then you can include words with any number of o's, so long as they only contain o's, and not any other vowels).
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.