Maximum number of objects that can be created as per given conditions | Function for finding the maximum number of objects from N type - 1 and M type - 2 items ; storing minimum of N and M ; storing maximum number of objects from given items ; Driver Code
function numberOfObjects ( N , M ) { let initial = Math . min ( N , M ) ; let final = Math . floor ( ( N + M ) / 3 ) ; return Math . min ( initial , final ) ; } let N = 8 ; let M = 7 ; document . write ( numberOfObjects ( N , M ) + " " ) ;