ALGORITHM CHALLENGE: 2

twitter logo ・1 min read

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
}
twitter logo DISCUSS
Classic DEV Post from Jun 24

What If I Want My Website to Last for 100 Years?

Algorithms and Challenge Questions profile image
I will be solving algorithm questions. Codewars: 8kyu

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❀️