Anjeev Singh Academy

Anjeev Singh Academy

Class 12 Web Application 803 CBSE Previous Year JavaScript Question Answer 2020 (Old)

Previous Year CBSE Board Question Paper 2022-2017



Answer Key of CBSE Previous Year Questions 2020 (Old) Examination

1 – Mark Questions

1. Which of the following is a JavaScript arithmetic operator?

(a) %          

(b) <           

(c)  &&       

(d) ? :

Answer: (a) %

2. To use random( ) in JavaScript the syntax is:

(a) random()         

(b) rand()   

(c) Random.random()    

(d) Math.random()

Answer: (d) Math.random()

3. What will be the output of the following JavaScript code:

            var name = [“Red”, “Blue”, “Yellow”, “Green”];


(a) Red                

(b) Green   

(c) Yellow   

(d) Blue

Answer: (b) Green

4. In JavaScript if a variable is defined using var in a compound statement ‘‘if’’, it will __________.  

(a) be visible to the entire compound ‘‘if’’ statement

(b) not be visible to the entire compound ‘‘if’’ statement

(c) be visible to the entire function

(d) not be visible to the entire function

Answer: (a) be visible to the entire compound ‘‘if’’ statement

5. To use an object’s methods or properties, we write the object’s name, ______ and then the method/property name.

(a) a dot[.]

(b) an asterisk[*]

(c) an ampersand[&]

(d) a pound[#]

Answer: (a) a dot [.]

2 – Marks Questions

5. Differentiate between Property and Method with example.

Answer: Differentiate between Property and Method:  

  • Properties define the characteristics of an object. Examples are color, length, name,

height, width etc.

  • Methods are the actions that the object can perform or that can be performed on the object. Examples are alert, confirm, write, open, close etc.

6. Explain Fall through with respect to switch statement with the help of an example.

Answer: Fall through is a condition in which if one case is true and does not contain the break statement, the next case is also executed.

var num = 1;



            case 1 : document.write(“One” + “<br>”);

            case 2 : document.write(“Two” + “<br>”);


            case 3: document.write(“Three” + “<br>”);


            default: document.write(“Invalid” + “<br>”);





3 – Marks Questions

7. Assuming Samar has created an external JavaScript file named ‘‘code.js’’ to include in his webpage. Write a code to link the above file in the HTML code of the webpage. Also mention where the code should be placed in the HTML code.

Answer: Code to link the JavaScript file is –

            <script type = “text/javascript”  src = “code.js” > </script>

This code should be placed under the <HEAD> </HEAD> tag in HTML.

8. What will be the final value of A and B on executing the following code:

A = 43


B = A+1

Answer: Final Value of A is 44 and B is 45.

5 – Marks Questions

9. Write a function that displays a prompt box which accepts a name and displays a greet message ‘‘hello <name>, Have a good day’’ when the user enters a name in a <p> (paragraph) which has an id ‘‘demo’’. The function header is as below:

function myfunc()






<p><strong>Click the button to demonstrate the prompt box.</strong></p>

<button onclick=”myFunction()”>try it</button>

<p id=”demo”></p>


function myFunction()


var x;

var person;

person=prompt(“please enter your name : “);

if(person != null)


x = (“hello” + person + “!how are u today?”);


document.getElementById(“demo”).innerHTML = x;





10. Write statements in JavaScript for the following:

(a)  To store date and time in a variable and then display date and time on the webpage.

(b)       (i) To store ‘‘Genius is one percent inspiration, 99% perspiration’’ in a variable.

(ii) To search ‘‘percent’’ in the string ‘‘Genius is one percent inspiration, 99% perspiration’’ and display it on the webpage.


(a) var datetime = new Date();


(b) (i)  var str = “Genius is one percent inspiration, 99% perspiration”;

      (ii) document.write(str.match(“percent”) + “<br>”);

Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top