Page 279 - Web_Application_v2.0_C12_Fb
P. 279

2.  Declare a function ‘stringsinjava’ in JavaScript to accept two string arguments. The function should
                         Convert both the strings to uppercase.
                         Search for string1 in string2 and display the string if found.
                         Replace all occurrences of letter ‘A’ with ‘*’ in string1.
                         Display first character of string2.
                 D.  Assertion and Reasoning questions.
                     Direction: Questions 1-2, consist of two statements – Assertion (A) and Reasoning (R). Answer these questions by
                    selecting the appropriate option given below:
                     a.  Both A and R are true and R is the correct explanation of A.
                     b.  Both A and R are true but R is not the correct explanation of A.
                    c.  A is true but R is false.
                    d.  A is false but R is true.
                    1.  Assertion (A): In JavaScript, typeof(null) returns "object".
                       Reason (R): null is considered an object in JavaScript due to a long-standing bug in the language.
                    2.  Assertion (A): The slice() method modifies the original array.
                       Reason (R): slice() creates a new shallow copy of the array, not affecting the original one.
                 E.  Statement-based questions.
                    Two statements are given. Statement 1 and Statement 2. Examine the statements and answer the question according
                    to the instructions given below:
                     a.  Statement 1 is True, Statement 2 is True
                    b.  Statement 1 is False, Statement 2 is False
                    c.   Statement 1 is True, Statement 2 is False
                    d.  Statement 1 is False, Statement 2 is True
                    1.  Statement 1: The onload event triggers when a webpage finishes loading.
                       Statement 2: The onchange event fires immediately when a user types something into an input box.
                    2.  Statement 1: Arithmetic operators in JavaScript only work with numbers.
                       Statement 2: The + operator can also concatenate strings in JavaScript.




                    LAB ACTIVITY                                                              21 st  Century   #Creativity
                                                                                                      #Technology Literacy
                                                                                                  Skills
                    1.   Revise entire JavaScript by watching the video – JavaScript Programming - Full Course (8 hour
                         duration) - https://www.youtube.com/watch?v=jS4aFq5-91M
                    2.   Write code for OK button to find the length of the string entered in a textbox on the webpage.
                    3.   Write a code in JavaScript to accept a number from the user and generate
                         a.  a random number greater than the number entered.
                         b.  next even number after the number entered.                              [CBSE PAPER 2020]

                    4.   Write a function that displays a prompt box which accepts a name and displays a greeting “Happy New
                         Year! <name>” in a paragraph which has an id “para1”.
                    5.   Create a simple game in JavaScript! Watch the video – The Easiest JavaScript Game Ever
                         https://www.youtube.com/watch?v=bG2BmmYr9NQ
                    6.   Create a Quiz by watching the video – How to create a Simple Quiz Using Html JavaScript
                         https://www.youtube.com/watch?v=rCVqQ8NKU2M






                                                                                                  JavaScript Part 2  277
   274   275   276   277   278   279   280   281   282   283   284