SyntaxStudy
Sign Up

Count Vowels

JAVASCRIPT Easy +15 XP
Problem Description
Write a function `countVowels(str)` that returns the number of vowels (a, e, i, o, u) in a string (case-insensitive).

Example:
countVowels('hello') → 2
countVowels('JavaScript') → 3
countVowels('rhythm') → 0

Test Cases

1
Input: countVowels('hello')
Expected: 2
2
Input: countVowels('JavaScript')
Expected: 3
3
Input: countVowels('rhythm')
Expected: 0
4
Input: countVowels('AEIOU')
Expected: 5
Your Solution