Return the Index of the First Vowel

Published by Helen Yu in

Create a function that returns the index of the first vowel in a string.

Examples

firstVowel("apple") ➞ 0

firstVowel("hello") ➞ 1

firstVowel("STRAWBERRY") ➞ 3

firstVowel("pInEaPPLe") ➞ 1

Notes

  • Input will be single words.
  • Characters in words will be upper or lower case.
  • "y" is not considered a vowel.
  • Input always contains a vowel.
Watch a quick demo on how Edabit works.