Page 389 - Webapplication11_C11_Flipbook
P. 389

5.  List 2 advantages and 2 disadvantages of JavaScript.
                   Ans.  Advantages:
                       •  Easy to learn
                       •  Regularly updated
                       •  Reduces load on server
                        Disadvantages:
                       •  Various browsers may often display content differently
                       •  Does not fully follow Object Oriented Programming concepts
                       •  Less secure
                 C.  Competency-based/Application-based questions.                                #Critical Thinking

                     1.   Reema went to a pizza shop where she saw a menu was available online on every table. Now, she is thinking of creating
                       the same menu in JavaScript. Which decision-making statements are appropriate for that?
                   Ans.  Switch case statement
                     2.  Devansh is a student of class 8. He wants to create a web page to perform different mathematical operations by taking
                       values from the user. But, he does not know which method of JavaScript is used to convert the input value into integer.
                       Suggest him the suitable method.
                   Ans.  parseInt()
                     3.   Meena is predicting  the output of the following code:

                       var grade='C';
                       var bonus;
                       switch(grade)
                       {
                       case'A':

                               bonus=5000;  break;
                       case'B':
                               bonus=3000;  break;
                       case'C':
                               bonus=2000;
                       case'D':
                         bonus=1500;

                       default:
                               bonus=0;
                       }
                       document.write(bonus);
                        But she is not getting the desired result. Help her to identify the problem correct it.
                   Ans.  bonus = 0 so only 0 will be displayed. Since ‘break’ statement is not being used in cases ‘C’ to default, all these cases will
                       be evaluated. Hence, bonus will get values from 2000 to 0. Only the last value that is 0 will be displayed.

                     4.  Ramesh is attempting to write the evaluation order for the expression 2*12/4-(8+9).Help him write the correct order of
                       evaluation for it.
                   Ans.  + in brackets → * → / → -







                                                                                                  JavaScript Part 1  387
   384   385   386   387   388   389   390   391   392   393   394