title: In array of objects count grouped values by certain key
body: <p>I have a following data:</p>
  <pre><code>const data2 = [
  {
    App: &quot;testa.com&quot;,
    Name: &quot;TEST A&quot;,
    Category: &quot;HR&quot;, 
    Employees: 7
  },
  {
    App: &quot;testd.com&quot;,
    Name: &quot;TEST D&quot;,
    Category: &quot;DevOps&quot;, 
    Employees: 7
  },
  {
    App: &quot;teste.com&quot;,
    Name: &quot;TEST E&quot;,
    Category: &quot;DevOps&quot;, 
    Employees: 7
  },
  {
    App: &quot;testf.com&quot;,
    Name: &quot;TEST F&quot;,
    Category: &quot;Business&quot;, 
    Employees: 7
  }
  ]
  </code></pre>
  <p>I want to get the count of distinct categories: Right now I am getting the list of all distinct categories but I'm unable to compute their count.</p>
  <p>Following snippet give me the Distinct Category:</p>
  <pre><code>  let uniqueCategory = [];
    for(let i = 0; i &lt; result.data.length; i++){    
        if(uniqueCategory.indexOf(result.data[i].Category) === -1){
          uniqueCategory.push(result.data[i].Category);        
        }        
    }
  </code></pre>
  <p>What changes should I make to get the Counts of those Categories in the <code>uniqueCategory</code> - something like following:</p>
  <pre><code>uniqueCategory = [
    {Category: &quot;DevOps&quot;, count: 5},
    {Category: &quot;Business&quot;, count: 4},
    ....
    {}
  ]
  </code></pre>