Page 141 - Computer Software Application TP - Volume 1
P. 141

COMPUTER SOFTWARE APPLICATION - CITS





                 let b = 5;
                 // Addition assignment (+=)

                 a += b; // equivalent to: a = a + b;
                 console.log(“Addition Assignment:”, a); // Output: 15
                 // Subtraction assignment (-=)
                 a -= b; // equivalent to: a = a - b;
                 console.log(“Subtraction Assignment:”, a); // Output: 10

                 // Multiplication assignment (*=)
                 a *= b; // equivalent to: a = a * b;
                 console.log(“Multiplication Assignment:”, a); // Output: 50
                 // Division assignment (/=)
                 a /= b; // equivalent to: a = a / b;

                 console.log(“Division Assignment:”, a); // Output: 10
                 // Modulus assignment (%=)
                 a %= b; // equivalent to: a = a % b;
                 console.log(“Modulus Assignment:”, a);
                 // Output: 0 (since 10 divided by 5 leaves no remainder)

                 </script>
                 </body>
                 </html>
              3  Save the program as a .html file

              4  Open the html file with a web browser
              5  Go to the browsers console tab and verify the output.





















           V. Ternary Operator
              1  Open the text editor
              2  Write the following codes
                 <html >

                 <head>
                 <title> Ternary Operator </title>



                                                           126
                               CITS : IT & ITES - Computer Software Application - Exercise 38
   136   137   138   139   140   141   142   143   144   145   146