Count vowels

Easy
32
86.8% Acceptance

Write a function countVowels(str), which takes a string str as an input. This function should return the total number of vowels in str.

Instructions

  • Return 0 if str has no vowels.
  • Assume that str may contain any alphanumeric characters.

Example test cases

countVowels("Hello world!"); // Output: 3 countVowels("This is a test"); // Output: 4 countVowels("No vowels here"); // Output: 0