title: Jquery json response iteration with condition
body: <p>I have this json response...</p>
  
  <pre><code>{
  "albums": {
    "data": [
       {
          "created_time": "2011-12-29T11:29:03+0000",
          "id": "10150573478667193",
          "name": "Timeline Photos",
          "photos": {
             "data": [
                {
                   "created_time": "2014-09-04T06:45:15+0000",
                   "source": "https://link.jpg",
                   "id": "10152743142372193",
                   "likes": {
                      "data": [
                         {
                            "id": "10202250935623343",
                            "name": "Name LastName"
                         }
                      ],
                      "summary": {
                         "total_count": 13
                      }
                   }
                }
             ]
          }
       }
    ]
    }
   }
  }
  </code></pre>
  
  <p>The actual response has a lot more album objects and photos objects but i shortened it for showing...Now what i am trying to do is iterate throught response and get the "source" link for the photo that has the highest total_count(most liked photo) in a couple of albums.I managed to get the highest total_count but i cant get the "source" link.Here is how i got highest total_count-</p>
  
  <pre><code>var array=[];
  $.each(response.albums.data,function(index,obj){
              //console.log("index1:" + index + " object1:" +obj);
              $.each(obj,function(index2,obj2){
              //console.log("index2:" + index2 + " object2:" +obj2);
              if(typeof obj2 == 'object'){
                  $.each(obj2.data,function(index3,obj3){
                  //console.log("index3:" + index3 + " object3:" +obj3);
                          $.each(obj3,function(index4,obj4){
                          //console.log("index4:" + index4 + " object4:" +obj4);
                              if(typeof obj4 == 'object'){
                                  $.each(obj4,function(index5,obj5){
                                  //console.log("index5:" + index5 + " object5:" +obj5);
                                      if(index5 == 'summary'){
                                          $.each(obj5,function(index6,obj6){
                                              //console.log("index6:" + index6 + " object6:" +obj6);
                                              array[array.length] = obj6; 
  
  
  
                                          });
  
                                      }
                                  });
                              }
                          });         
                  });
              }
              }); 
          });
          var mostLikedNumber=Math.max.apply(Math,array);
          console.log("Most liked - " +mostLikedNumber);
  </code></pre>
  
  <p>Any help is appreciated!</p>