Relation Operator
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>
- </title>
- </head>
- <body>
- <script type="text/javascript">
- var a = 21;
- var b = 10;
- //equal to
- if (a == b) // (a=21 == b=10) is False; Therefore a is not equal to b.
- //the two given values are equal to each other then result will be True, Otherwise it returns False.
- {
- document.write(" a is equal to b "+"<br>");
- }
- else
- {
- document.write(" a is not equal to b"+"<br>"); // document.write() use for print line.
- }
- //grater than
- if (a > b) //(a=21 > b=10) is True; Therefore a is grater than b.
- //the first value is grater than the second value then result will be True, Otherwise it returns False.
- {
- document.write("a is greater than b"+"<br>");
- }
- else
- {
- document.write("a is not greater than b"+"<br>"); //"<br>" use for linebreak.
- }
- //less than
- if (a < b) //(a=21 < b=10) is False; Therefore a is not less than b.
- //the first value is less than the second value then result will be True, Otherwise it returns False.
- {
- document.write("a is less than b"+"<br>");
- }
- else // when If condition flase then; else condition executed.
- {
- document.write("a is not less than b"+"<br>");
- }
- //grater than or equal to
- if (a >= b) //(a=21 >= b=10) is True; Therefore a is grater than or equal to b.
- //the first value is grater than or equal to the second value then result will be True, Otherwise it returns False.
- {
- document.write("a is greater than or equal to b"+"<br>");
- }
- else
- {
- document.write("a is not greater than or equal to b"+"<br>");
- }
- //less than equal to
- if (a <= b) //(a=21 <= b=10) is False; Therefore a is not less than or equal to b.
- //the first value is less than or equal to the second value then result will be True, Otherwise it returns False.
- {
- document.write("a is less than or equal to b"+"<br>");
- }
- else
- {
- document.write("a is not less than or equal to b"+"<br>");
- }
- </script>
- </body>
- </html>
//Execute
//Output
/*
//equal to
a is not equal to b
//grater than
a is greater than b
//less than
a is not less than b
//greater than or equal to
a is greater than or equal to b
//less than or equal to
a is not less than or equal to b
*/
//ThE ProFessoR