JavaScript – Relational Operators

Relational operators: These operators return a boolean values by validating the relation between data. Operators are >, < , >=, <=, ==, !=

<html>
            <body>
                        <script>
                                    var a=5, b=3;
                                    document.write(a + ” > ” + b + ” = ” + (a>b) + “<br/>”);
                                    document.write(a + ” < ” + b + ” = ” + (a<b) + “<br/>”);
                                    document.write(a + ” == ” + b + ” = ” + (a==b) + “<br/>”);
                                    document.write(a + ” != ” + b + ” = ” + (a!=b) + “<br/>”);
                        </script>
            </body>
</html>

Condition to check the number is Positive or Negative:

Variables:
var a=?;
 
Condition:
            a >= 0

Condition to check the number is equal to zero or not:

Variables:
var a=?;
 
Condition:
            a == 0

Condition to check the 2 numbers equal or not:

Variables:
var a=?, b=?;
 
Condition:
            a ==b

Condition to check First Num greater than Second Num or Not:

Variables:
var a=?, b=?;
 
Condition:
            a > b

Condition to check sum of 2 numbers equal to 10 or not:

Variables:
var a=?, b=? ;
 
Condition:
            a+b == 10 ;

Condition to check the number divisible by 3 or not:

Variables:
var n=?;
 
Condition:
            n % 3 == 0

Condition to check the number is Even or not:

Variables:
var n=?;
 
Condition:
            n % 2 == 0

Condition to check the last digit of Number is 0 or not:

Variables:
var n=?;
 
Condition:
            n % 10 == 0

Condition to check average of 4 subjects marks greater than 60 or not:

Variables:
var m1=?, m2=?, m3=? , m4=? ;
 
Condition:
            (m1 + m2+ m3+ m4)/4 >= 60

Condition to check the sum of First 2 numbers equals to last digit of 3rd num or not:

Variables:
var a=?, b=? , c=? ;
 
Condition:
            a + b == c% 10

Condition to check the given quantity of fruits exactly in dozens or not:

Variables:
var quantity = ?;
 
Condition:
            quantity%12 == 0
Scroll to Top