Originally Posted by rnd me
is there anything map/filter can't do?
r=[ 77, 101, 191, 91, 91, 191, 191, 191, 191,343 ]
r.indexOf(Math.max.apply(0,r.filter(Number))); // === 191
Yes - report the mode when two values occur the same number of times. Obviously you can have more than one mode.
Having two modes is called "bimodal". More than 2 modes is called "multi-modal".
felgall's and Old Pedant's scripts do this.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 12-03-2012 at 08:55 AM..