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 6

How do you onboard a new team member?

My team have a lot of roles to fill this year and recruitment is underway. I'm curious, when you joined your team, what made it a smooth experience?

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