Page 340 - Webapplication11_C11_Flipbook
P. 340

Following is the output of the above code:













                                               Lab Assignment ‘n Activity                     #Interdisciplinary




                 1.  Create JavaScript programs to calculate the following and display the result with appropriate messages:
                      Area and perimeter of a rectangular lawn
                      Simple Interest
                 2.  Try the following code snippets and check the output:
                      document.write( “WELCOME” + “TO” + “ALL”)
                      document.write (10+12+ “234”)



              Comparison Operators
              To determine equality or difference between variables or values, comparison operators are utilised in logical statements.
              The comparison operators are explained in the table below, assuming x = 8.

               Operator       Name                           Description                       Example       Output

                  ==     equal to        It is used to compare the value of a variable against the   x==7     false
                                         value of other variable or directly with some other value.   x==8    true

                  !=     not equal       It is used to check if two operands being evaluated are   x!=8       false
                                         not equal. Then this gives the value true.
                   >     greater than    It  is  used  to  check  whether  any  expression  generates   x>8   false
                                         a value greater than other expressions; if so, then the
                                         value would evaluate to true; else false.
                   <     less than       It is used to check whether any expression generates a   x<8         false
                                         value less than other expressions; if so, then the value
                                         would evaluate to true; else false.

                  >=     greater than or   It is used to check whether the left operand is greater   x>=8     true
                         equal to        than or equal to the right operand.

                  <=     less than or    It is used to check whether the left operand is less than   x<=8     true
                         equal to        or equal to the right operand.

                  ===    Triple Equals   It is used to compare the equality of two operands with a   x===”8”  false
                                         data type. If both the value and the data type are equal,
                                         then the condition is true, otherwise false.


              Let us create a JavaScript program to use comparison operators.
              <!DOCTYPE html>

              <HTML>
              <HEAD>
                338     Touchpad Web Applications-XI
   335   336   337   338   339   340   341   342   343   344   345