← Back to challenges

Vowel Sandwich

JavaScriptHardstringslanguage_fundamentalsvalidationregexconditions

Instructions

Create a function which validates whether a 3 character string is a vowel sandwich. In order to have a valid sandwich, the string must satisfy the following rules:

  • The first and last characters must be a consonant.
  • The character in the middle must be a vowel.

Examples

isVowelSandwich("cat") ➞ true

isVowelSandwich("ear") ➞ false

isVowelSandwich("bake") ➞ false

isVowelSandwich("try") ➞ false

Notes

  • Return false if the word is not 3 characters in length.
  • All words will be given in lowercase.
  • y is not considered a vowel.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Measure the Depth of Emptiness