Page 278 - Web_Application_v2.0_C12_Fb
P. 278

<P ID="Cel"></P>
                    <SCRIPT>
                    function toFarhenheit(temp){
                    var C = (temp - 32) * 5/9;
                    return C + " °C";
                    };
                    function toCelsius(temp){
                    var F = (temp * 9/5) + 32;
                    return F + " °F";
                    };
                    document.getElementById("Far").innerHTML = toFarhenheit(98.6);
                    document.getElementById("Cel").innerHTML = toCelsius(32);
                    </SCRIPT>
                    </BODY>
                    </HTML>
              B.  Long answer type questions.
                  1.  Explain the following functions with examples:
                    i.  substring()                                   ii.  concat()
                    iii.  confirm()                                  iv.  shift()
                  2.  What is a function? Write a user defined function to display an alert box with the message “The biggest robot is
                    Mononofu”.

                  3.  Give the output of the following code snippet with justification:       [CBSE SAMPLE PAPER 2020]
                     i.  for (i=1;i<1;i++)

                     document.write("hello");
                     document.write("ByeBye");

                  4.  Write a JavaScript program that takes a string and returns the number of vowels in it.
                  5.  Write a JavaScript program with a function findSecondMax() to find the second maximum number out of five
                    numbers passed to the function as arguments.

                  6.  Explain anonymous functions in JavaScript with examples.
                  7.  What are the important properties of an anonymous function in JavaScript? Give an example.
                  8.  Write a script using JavaScript which accepts 2 strings from the user and passes them to a function. The function
                    checks whether they are anagram of each other or not. [Hint: Two strings are called anagram if they contain the
                    same characters but in different order e.g. “listen” and “silent”.

              C.   Competency-based/Application-based questions.                             21 st  Century   #Critical Thinking
                                                                                                 Skills
                  1.  Consider the following code:
                    const fruits = ["Apple", "Mangoes", "Orange", "Banana"];
                     Write command in JavaScript to:
                     add an item “Guava “ to the array fruits in the last.

                     remove first element from the array.
                     display number of elements in the array.

                     add following array to an array “fruits”. var veg=[“Potato”, “Brinjal”, “Gourd”];

                276   Touchpad Web Applications (Ver. 2.0)-XII
   273   274   275   276   277   278   279   280   281   282   283