Maximize the missing values in given time in HH : MM format | Function to find the maximum time by replacing ' ? ' by any digits ; If the 0 th index is ' ? ' ; If the 1 st index is ' ? ' ; If the 3 rd index is ' ? ' ; If the 4 th index is ' ? ' ; Return new string ; Driver Code
function maxTime ( s ) { s = s . split ( " " ) if ( s [ 0 ] == ' ' ) { if ( s [ 1 ] <= ' ' s [ 1 ] == ' ' ) s [ 0 ] = ' ' ; else s [ 0 ] = ' ' ; } if ( s [ 1 ] == ' ' ) { if ( s [ 0 ] != ' ' ) { s [ 1 ] = 9 ; } else s [ 1 ] = 3 ; } if ( s [ 3 ] == ' ' ) s [ 3 ] = ' ' ; if ( s [ 4 ] == ' ' ) s [ 4 ] = ' ' ; document . write ( s . join ( " " ) ) ; } let S = " " ; maxTime ( S ) ;