Count the vowels
- O(n) · Medium
- Full plan
- Python
- JavaScript
- strings
- loops
Problem
Write a function that takes a text and returns how many vowels it has. Uppercase and lowercase both count, and so do vowels with an accent (á, é, í, ó, ú): some words carry one, like "résumé".
Examples
"hello" → 2
"" → 0
"RÉSUMÉ" → 3
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def count_vowels(text):
passJavaScript
function countVowels(text) {
}Solve this challenge
It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.