Check whether product of integers from a to b is positive , negative or zero | Function to check whether the product of integers of the range [ a , b ] is positive , negative or zero ; If both a and b are positive then the product will be positive ; If a is negative and b is positive then the product will be zero ; If both a and b are negative then we have to find the count of integers in the range ; Total integers in the range ; If n is even then the resultant product is positive ; If n is odd then the resultant product is negative ; Driver code
function solve ( a , b ) { if ( a > 0 && b > 0 ) { document . write ( " " ) ; } else if ( a <= 0 && b >= 0 ) { document . write ( " " ) ; } else { let n = Math . abs ( a - b ) + 1 ; if ( n % 2 == 0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } } let a = - 10 ; let b = - 2 ; solve ( a , b ) ;