Counting Elements in Array

Submitted By:
lucascaton

Difficulty:
Easy

Tags:
arrays

Instructions:
Count elements in an Array by returning a hash with keys of the elements and values of the amount of times they occur.

Hidden Code:
There is hidden code with assertions that is also being run to test out your code.

Code:
test = ['cat', 'dog', 'fish', 'fish']

def count(array)
  ___
end

assert_equal ({ 'cat' => 1, 'dog' => 1, 'fish' => 2 }), count(test)

Your Solution

Ruby 1.9.3

Back to Problems