For all vowels in a string, I'm trying to print the amount of the vowels. If I push every instance of a vowel to a new array, then the length of the array + 1 would be the answer. I don't know if my push is failing. Any help would be appreciated.
def count_vowels(string)
arr = ['a', 'e', 'i', 'o', 'u']
letters = string.split("")
letters.each do |x|
if x == arr.any?
vowels = vowels.push(x)
print vowels.length
else
print 0
end
end