Find the Batting Average of a batsman | Function to find the average of a batsman ; Calculate number of dismissals ; Check for 0 times out ; Calculate batting average ; Driver code
function averageRuns ( runs , matches , notout ) { let out1 ; out1 = matches - notout ; if ( out1 == 0 ) return - 1 ; let avg = parseInt ( ( runs ) / out1 , 10 ) ; return avg ; } let runs = 10000 ; let matches = 250 ; let notout = 50 ; let avg = averageRuns ( runs , matches , notout ) ; if ( avg == - 1 ) document . write ( " " ) ; else document . write ( avg ) ;