title: grouping the same value returned by $.each jquery
body: <p>I am returning json objects that turned out to have the same value with them. I would like to avoid repeating the same value and just merged them into on, including the other values that come with them. I have been trying to get the length of the objects with the same value so that I could just do the merge, but I am not getting anywhere. All i am having is the actual length of the value, not how many times they turned up. </p>
  
  <pre><code>$.each(data, function(i, val)){
    var city = val.city;
    var name = val.name;
  }
  
  &lt;!-- printing the results, they would all like this --&gt;
  Los Angeles
    George Martin
  Los Angeles 
    Alex Dell
  Los Angeles
    Tom Front
  Sao Paulo
    Jean Mont
  Sao Paulo 
    Steve Bald
  </code></pre>
  
  <p>I want to group them by city. So that it wont look redundant. I have been trying this to work. </p>
  
  <pre><code>var newcity = null;
  if(newcity !== city){
    city = city;
  }
  newcity = city;
  </code></pre>
  
  <p>i also try this one, which is absolutely stupid. counting the results for the city</p>
  
  <pre><code>var countcityobj = val.city.length;
  </code></pre>
  
  <p>Can anyone guide me on how to do this with jquery? thanks. </p>