Most Frequent Element
Find the value that appears most often. Tally counts in an object as you go, and track the current leader.
Your task
Write mostFrequent(arr) returning the element that appears most often. The
input always has at least one element; if there's a tie, return the one that
reached the top count first.
β‘ 40 XP
solution.jsRuns in your browser
Loading editorβ¦
Tests3 to pass
numbers
strings
single
Run your code to check these.