← Back to challenges

Return the Index of the First Vowel

JavaScriptHardstringslanguage_fundamentalsloopsregex

Instructions

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.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Is it True?