How to check if two integers have opposite signs in JavaScript

1 Answer

0 votes
let x = 3, y = -9;            
let b = ((x ^ y) < 0); 
console.log(b);
      
x = 5, y = 6;
b = ((x ^ y) < 0); 
console.log(b);
      
 
    
/*
run:
     
true
false
      
*/

 



answered Mar 22, 2019 by avibootz
edited Jul 24, 2025 by avibootz

Related questions

1 answer 178 views
1 answer 170 views
1 answer 181 views
1 answer 180 views
1 answer 182 views
1 answer 211 views
...