Check if the minute value is valid , if not valid then skip the current iteration , to check ' minute ' value flag is set to 0.
if ( ! isValid ( String . fromCharCode ( m1 ) , String . fromCharCode ( m2 ) , str , 0 ) ) { continue ; } if ( inRange ( i , j , L , R ) ) { displayTime ( i , j ) ; return ; } } } if ( inRange ( i , j , L , R ) ) displayTime ( i , j ) ; else document . write ( " " ) ; }