Find the Most Frequent Element in an Array

Published by Matt in

Create a function that takes an array and returns the most frequently occurring element contained within it.

Examples

find_frequent([3, 7, 3]) ➞ 3

find_frequent([nil, "hello", true, nil]) ➞ nil

find_frequent([false, "up", "down", "left", "right", true, false]) ➞ false

Notes

N/A

Watch a quick demo on how Edabit works.