Average of even numbers till a given even number | Function to calculate the average of even numbers ; driver function
function averageEven ( n ) { if ( n % 2 != 0 ) { document . write ( " " ) ; return - 1 ; } return ( n + 2 ) / 2 ; } let n = 16 ; document . write ( averageEven ( n ) ) ;