Q:

Write a JavaScript program to check from two given integers, whether one is positive and another one is negative

0

 Write a JavaScript program to check from two given integers, whether one is positive and another one is negative. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function positive_negative(x, y)
{
  if ((x < 0 && y > 0) || x > 0 && y < 0) 
  {
    return true;
  }
  else 
  {
    return false;
  }
}
console.log(positive_negative(2, 2));
console.log(positive_negative(-2, 2));
console.log(positive_negative(2, -2));
console.log(positive_negative(-2, -2));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now