+ 3
For Ruby -> Collection -> Letter frequency counter
how can we make it so it will print / puts only the letters that exist in the phrase and not all the alphabet? what if statement shall we use? i thought and tried something like the one that has the question following this lesson but it didn't work. thanks to whom ever will help. :-)
1 Resposta
+ 1
freqs ={}
freqs.default = 0
text = "I like Ruby, this is my favorite on Sololearn!!"
text.each_char { |char| freqs[char] += 1}
puts freqs