Skip to main content

//Relation Operator

Relation Operator 


  1.  <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>
  6. </title>
  7. </head>
  8. <body>
  9. <script type="text/javascript">

  10. var a = 21;
  11. var b = 10;

  12. //equal to
  13. if (a == b) // (a=21 == b=10) is False; Therefore a is not equal to b.
  14.            //the two given values are equal to each other then result will be True, Otherwise it returns False.
  15. {
  16. document.write(" a is equal to b "+"<br>");
  17. else 
  18. {
  19. document.write(" a is not equal to b"+"<br>"); // document.write() use for print line.
  20. }

  21. //grater than
  22. if (a > b) //(a=21 > b=10) is True; Therefore a is grater than b.
  23.             //the first value is grater than the second value then result will be True, Otherwise it returns False.
  24. {
  25. document.write("a is greater than b"+"<br>");
  26. else 
  27. {
  28. document.write("a is not greater than b"+"<br>"); //"<br>" use for linebreak.
  29. }


  30. //less than
  31. if (a < b) //(a=21 < b=10) is False; Therefore a is not less than b.
  32.             //the first value is less than the second value then result will be True, Otherwise it returns False.
  33. {
  34. document.write("a is less than b"+"<br>");
  35. else // when If condition  flase then; else condition executed.
  36. {
  37. document.write("a is not less than b"+"<br>");
  38. }

  39. //grater than or equal to
  40. if (a >= b) //(a=21 >= b=10) is True; Therefore a is grater than or equal to b.
  41.              //the first value is grater than or equal to the second value then result will be True, Otherwise it returns False.
  42. {
  43. document.write("a is greater than or equal to b"+"<br>");
  44. else 
  45. {
  46. document.write("a is not greater than or equal to b"+"<br>");
  47. }

  48. //less than equal to
  49. if (a <= b) //(a=21 <= b=10) is False; Therefore a is not less than or equal to  b.
  50.              //the first value is less than or equal to  the second value then result will be True, Otherwise it returns False.
  51. {
  52. document.write("a is less than or equal to b"+"<br>");
  53. else 
  54. {
  55. document.write("a is not less than or equal to b"+"<br>");
  56. }
  57. </script>
  58. </body>
  59. </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