Write a function countVowels(str)
, which takes a string str
as an input. This function should return the total number of vowels in str
.
- Return 0 if
str
has no vowels. - Assume that
str
may contain any alphanumeric characters.
countVowels("Hello world!"); // Output: 3
countVowels("This is a test"); // Output: 4
countVowels("No vowels here"); // Output: 0