title: Count duplicates within an Array of Objects
body: <p>I have an array of objects as follows within my server side JS:</p>
  
  <pre><code>[
      {
          "Company": "IBM"
      },
      {
          "Person": "ACORD LOMA"
      },
      {
          "Company": "IBM"
      },
      {
          "Company": "MSFT"
      },
      {
          "Place": "New York"
      }
  ]
  </code></pre>
  
  <p>I need to iterate through this structure, detect any duplicates and then create a count of a duplicate is found along side each value. </p>
  
  <p>Both of the values must match to qualify as a duplicate e.g. "Company": "IBM" is not a match for "Company": "MSFT".</p>
  
  <p>I have the options of changing the inbound array of objects if needed. I would like the output to be an object, but am really struggling to get this to work.</p>
  
  <p>EDIT: Here is the code I have so far where processArray is the array as listed above.</p>
  
  <pre><code>var returnObj = {};
  
      for(var x=0; x &lt; processArray.length; x++){
  
          //Check if we already have the array item as a key in the return obj
          returnObj[processArray[x]] = returnObj[processArray[x]] || processArray[x].toString();
  
          // Setup the count field
          returnObj[processArray[x]].count = returnObj[processArray[x]].count || 1;
  
          // Increment the count
          returnObj[processArray[x]].count = returnObj[processArray[x]].count + 1;
  
      }
      console.log('====================' + JSON.stringify(returnObj));
  </code></pre>