Page 356 - Webapplication11_C11_Flipbook
P. 356

2.  Predict the output of the following code:

                    <HTML>
                    <BODY>
                    <H1> JavaScript </H1>
                    <script type="text/javascript">
                    var C=prompt("Enter temperature in Celcius")
                    alert("The Temperature in Fahrenheit is "+((C*9/5)+32))
                    </SCRIPT>
                    </BODY>
                    </HTML>
                 3.  Predict the output of the following code:
                    <HTML>
                    <BODY>
                    <H1> JavaScript </H1>
                    <script type="text/javascript">
                    var text;
                    var a = confirm("Do you know about Metaverse?");
                    if (a == null || a == "")
                    {
                        text = "Prompt cancelled by user";
                    }
                    else
                    {
                     text = "The metaverse is a fictional iteration of the Internet as a single,
                    universal, and immersive virtual world assisted by the usage of virtual
                    reality and augmented reality headsets.";
                    }
                      document.write(text);
                    </SCRIPT>
                    </BODY>
                    </HTML>




                 4.21 TYPES OF CONTROL STATEMENTS
              In JavaScript, control statements are used to control the flow of execution in a program. They allow you to make
              decisions, execute code repeatedly, and handle different situations. There are three main types of control statements
              in JavaScript:

              Ð ÐConditional Statements: Conditional statements allow your program to make decisions based on certain conditions.
                 They execute specific blocks of code depending on whether a condition evaluates to true or false.

              Ð ÐLooping (Iterative) Statements: Looping statements allow you to execute a block of code repeatedly until a certain
                 condition is met. They are useful for tasks that require repeated execution, such as iterating over arrays or executing
                 a block multiple times.


                354     Touchpad Web Applications-XI
   351   352   353   354   355   356   357   358   359   360   361