title: Counting Occurrences of Object Values
body: <p>I am trying to loop through some data in a JSON file and count the number of same cities/occurrences...</p>
  
  <pre><code>var json = [
    { "city": "California" },
    { "city": "California" },
    { "city": "California" },
    { "city": "Texas" },
    { "city": "Florida" }
  ];
  
  var obj = {};
  
  for (var i = 0, j = json.length; i &lt; j; i++) {
    if (obj[json[i]]) {
      obj[json[i]]++;
    }
    else {
      obj[json[i]] = 1;
    } 
  }
  
  console.log(obj);
  </code></pre>
  
  <p><strong>JSFiddle:</strong> <a href="http://jsfiddle.net/f2939ucw/" rel="nofollow noreferrer">http://jsfiddle.net/f2939ucw/</a></p>
  
  <p>The problem is that the object returned is only returning back the number of objects within the array and not the same occurrences of cities.</p>