Challenge
Return the number (count) of vowels in the given string.
We will consider a, e, i, o, and u as vowels for this Kata. The input string will only consist of lower case letters and/or spaces.
Solution
rust
fn get_count(string: &str) -> usize {
let vowels: &str = "aeiou";
let mut vowels_count: usize = 0;
for c in string.chars() {
if vowels.contains(c) {
vowels_count = vowels_count + 1;
}
}
vowels_count
}
Top comments (0)