Write a method def duplicate_counter(array) that takes an array and returns a number that represents how many duplicate elements were in an array:
duplicate_counter([1, 7, 7, 7, 3, 5])would return2because there are 2 sets of duplicate7s.duplicate_counter([5, 7, 9])would return0because there are no duplicate elements.duplicate_counter([0,-5,-5,33,33,33])would return3because there are 3 sets of duplicates (1 set of-5s and 2 sets of33s).
Notes:
- Do the assignment with TDD if you want some TDD practice (you likely will need another file in addition to
code.rbfor your test suite if you choose to do this)!