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. } 
  18. else 
  19. {
  20. document.write(" a is not equal to b"+"<br>"); // document.write() use for print line.
  21. }

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


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

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

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