Answer the question
In order to leave comments, you need to log in
How to simplify code using block?
How to make the following code less verbose:
# frozen_string_literal: true
vowels = %w[a e i o u]
found = {}
founded = 0
puts 'Puts the word: '
words = gets.chomp.chars
words.each do |n|
next unless vowels.include?(n)
found.store(n, 0)
puts "We have #{founded + 1} vowel(s)."
found[n] += 1
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question