title: Underscore Javascript building frequency graph
body: <p>I am currently pretty new to JS and underscore. I want to see which particular number occurs the most in a given array, (say var a for now). As an avid python user, I am used to summing it up in a frequency telegraph and then output it in tuples [(1, 3), (2, 2), ... ] and then sort it like that. </p>
  
  <p>What is the best way to do so in javascript? </p>
  
  <pre><code>function votesTied() { 
    var a = [1, 2, 3, 1, 2, 4, 6, 1, 7];
    var tele = {};
    _.each(a, function(key) { 
      if (tele[key]) { 
        tele[key]++;
      } else { 
        tele[key] = 1;
      }
    });
  
    var items = _.map(tele, function(frequency,key) { return [key,frequency]; });
    var results = _.sortBy(items, function(tuple) { return -1 * tuple[1]; }).value(); 
  
    return results.length &gt; 1 &amp;&amp; results[0][1] == results[1][1];
  }
  </code></pre>
  
  <p>I ask so because I can literally do all this in 1 line of python. I am sure there's a more elegant way to write this in underscore or javascript. </p>