I am new to ruby and this might be a simple solution but i can't seem to figure out how to output the number of the most frequency occurrence in the array. Assume that animals is an array of strings. Write a set of Ruby statements that reports to output how many times the word “cat” appears in the array. For example, if the array animals has the contents of [“cat”, “dog”, “cat”, “cat”, “cow”], your script should write out the number 3. Here is what i have so far, which gives me an output of cat but i want to just show how many times it repeats. Thanks!
array = [ "cat", "dog", "cat", "cat", "cow" ]
repeat_item = array.uniq.max_by{ |i| array.count( i ) }
puts repeat_item