Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_number_of_vowels (str)
- string = str.downcase
- count = string.scan(/[aeoui]/).count
- if count == 1
- return "This string has #{count} vowel"
- else
- return "This string has #{count} vowels"
- end
- end
- count_number_of_vowels ("hello world")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement