Vowel Sandwich

Published by bangyen in

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

is_vowel_sandwich("cat") ➞ true

is_vowel_sandwich("ear") ➞ false

is_vowel_sandwich("bake") ➞ false

is_vowel_sandwich("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.
Watch a quick demo on how Edabit works.