Calculating the mode value of an array

The function for returning the mode value of an array works on every test except one. When I pass the following array through the function, I get a TypeError. I figured out that it has something to do …

Get the element with the highest occurrence in an array

I’m looking for an elegant way of determining which element has the highest occurrence (mode) in a JavaScript array. For example, in [‘pear’, ‘apple’, ‘orange’, ‘apple’] the ‘apple’ element is the …