simple-exercises/ruby-exercises/very-easy.rb
# Write a method that takes a string and returns the number of vowels
# in the string. You may assume that all the letters are lower cased.
# You can treat "y" as a consonant.
Write a method that takes a string and returns the number of vowels
in the string. You may assume that all the letters are lower cased.
You can treat "y" as a consonant.
Write a method that takes a string and returns the number of vowels in the string . You may assume that all the letters are lower cased . You can treat " y " as a consonant .
def count_vowels string
  vowels = ["a", "e", "i", "o", "u"]
  n = 0
  (0...string.length).each do |i|
    if vowels.include?(string[i])
      n += 1
    end
  end
  n
end
def count_vowels string vowels = [ "a" , "e" , "i" , "o" , "u" ] n = 0 ( 0 ... string . length ) . each do | i | if vowels . include? ( string [ i ] ) n += 1 end end n end
Write a method that takes a string and returns the number of vowels
in the string.
Write a method that takes a string and returns the number of vowels in the string .
string
<not_specific>