title: Count amount of time a number appears in an Array
body: <p>So I have a dice rolling function. I want to roll 2 dice 20 times, each time I roll, I want to add those numbers, and then I want to see how many times the sum appears, and put that number into an array.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function Dice() {
    this.roll = function() {
      var randomValue = Math.ceil(Math.random() * 6);
      this.side = randomValue;
      return this.side;
    }
  }
  
  var dice1 = new Dice();
  var dice2 = new Dice();
  
  function getAmount() {
    var finalArray = [];
  
    function diceSum() {
      var sum = dice1.roll() + dice2.roll();
      return sum;
    }
  
    var trackSum = [];
    for (var i = 1; i &lt;= 20; i++) {
      trackSum.push(diceSum());
    }
  
  
    var reduced = trackSum.reduce(function(acc, sum, i, arr) {
      return acc.i += sum;
    }, {});
    return reduced;
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>so I get <code>trackSum</code> which has 20 numbers in an array which, each number is the sum of the 2 dice rolled. If <code>sum = 2</code> and it appears 5 times, <code>sum = 4</code>, appears 2 times, <code>sum = 3</code>, appears 1 time, final array should look like </p>
  
  <pre><code>[5, 2, 1]
  </code></pre>
  
  <p>So far I tried a <code>reduce</code> method, <code>filter</code>, and <code>forEach</code>. I just can't figure out how to compare the numbers to see how many times it's appearing. Any help would be appreciated. Thanks!</p>