title: JavaScript - Count and remove duplicates from array of objects with es6
body: <p>I'm trying to fix this, but I'm a little bit stuck and need some help/advise. I'm trying to get to know es6 better and better, but I'm clueless on what's the best way to fix my problem.</p>
  
  <p>I have a large json I'm fetching which looks somewhat like this:</p>
  
  <pre><code>[
      {
          "company": "Google",
          "location": "USA",
          "email": null
      },
      {
          "company": "Microsoft",
          "location": "USA",
          "email": "mail@mail.com"
      },
      {
          "company": "Google",
          "location": "NLD",
          "email": "mail@mail.com"
      }
  ]
  </code></pre>
  
  <p>I display these in a table and want to add checkbox filters but I also want to add a count next to it, like so:</p>
  
  <pre><code>[x] Google (2)
  [ ] Microsoft (1)
  // other function call
  [ ] mail@mail.com (2)
  </code></pre>
  
  <p>I have this function I call every every key (company, location, email):</p>
  
  <pre><code>function filterArr(data, key) {
  
      data.forEach(element =&gt; {
  
          let countedData = data.filter((el) =&gt; {
              return el[key] == element[key]
          }).length;
  // console.log(element[key] + ": " + countedData);
      });
  
      data = data.filter((item, index, self) =&gt; self.findIndex( t =&gt; t[key] === item[key] &amp;&amp; item[key] != null) === index )
  // console.log(data)
      return data;
  }
  
  filterArr(data, "company");
  </code></pre>
  
  <p>The output I'm trying to achieve with the above function is: 
  Google: 2
  Microsft: 1</p>
  
  <p>The foreach is correctly counting the key values, but obviously logging the following:
  Google: 2
  Microsoft: 1
  Google: 2</p>
  
  <p>And the filter console.log shows Google and Microsoft (just once, like I want :)</p>
  
  <p>Now I need to combine these 2, but I'm not sure how to and what's the best way to do so. (see my fiddle: <a href="https://jsfiddle.net/z359qo1d/" rel="nofollow noreferrer">https://jsfiddle.net/z359qo1d/</a>)</p>
  
  <p>Do you know what to do next?</p>