I have this code which im echoing data from jquery success .
   for(i = 0;i < dat.id.length; i++){
           // im echoing data here 
    }
and i want check for the highest value in dat.voteup
like that (It works)
    var maxvoteup = 0; 
    if (dat.voteup[i] - dat.votedown[i] ==maxvoteup) {
                    console.log(maxvoteup);
        //i want fetch maxvoteup here
     }
But i want make just one For loop not two . How can i do that pls?
EDIT:
  var maxvoteup = 0; 
    for (i = 0;i < (dat.voteup-dat.votedown).length ;i++) {
         if (dat.voteup[i] - dat.votedown[i]>maxvoteup) {
            maxvoteup = dat.voteup[i] - dat.votedown[i];
                    console.log(maxvoteup);
        //i want fetch maxvoteup here
      }
     }
EDIT2: this is what im getting in my jquery response , But actually my max vote is 10 not 8 . 8 is just voted up to 8 , but there is other votes which is 10.
   {"status":"success","message":[],"date_edited":[2016-04-21 21:31:25],"voteup":[],"votedown":[8],"id":[]}
 
     
    