Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <p id="hello">Hello World</p>
</body>
</html>
 
    var a = [2, 2, 2, 4, 4, 5, 2, 2, 3, 1, 2, 1, 1];
    var o = {},
        i = 0,
        m = {m:0,t:null},
        t = {m:0,t:null},
        len = a.length;
    for ( ; i < len ; i++ ) {
        o[ a[i] ] = ( o[ a[i] ] || 0 ) + 1;
    }
    for ( i in o ) {
        t = {
            m: o[i],
            i: i
        }
          
          console.log(t, m);
          
        m = m.m < t.m ? t : m
    }
    alert(m.i + " is the highest presented " + m.m + " times");
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers