title: How to count number of particular items in a list in AngularJS app
body: <p>I am using the following code to try and generate a list showing the count of each item in the <code>letters</code> list within an AngularJS controller:   </p>
  
  <pre><code>$scope.letters = ['a','b','c'];
  $scope.letterdata = ['a','b','a','c','b','a'];
  
  $scope.counts = $scope.letters.map(function (x) {
      $scope.letterdata.filter(function (y) {
          return (x == y);
      }).length;
  });
  </code></pre>
  
  <p>I would like to get <code>[3,2,1]</code> as the output, but this is showing as <code>[null,null,null]</code>.</p>