Increment i if new highest value occurs Increment j if new lowest value occurs
for ( let n in arr ) { if ( h_score < arr [ n ] ) { h_score = n ; i ++ ; } if ( l_score > n ) { l_score = n ; j ++ ; } } document . write ( " " ) ; document . write ( " " + i + " " ) ; document . write ( " " ) ; document . write ( " " + j ) ; }