Javascript TUTORIAL Quiz



Javascript Quiz # 1

The first Javascript Quiz covering Chapters 1 to 5 of Tutorial.


Q1. Which of the following is NOT true about javascript.

A . Javascript can be embedded within HTML
B . A file containing Javascript can be viewed in a local browser with javascript enabled.
C . You need a compiler to compile the scripts of Javascript
D. Javascript is totally different from Java

Q2. What is the correct way to write the conditional statement for executing some statements only if x is equal to 12 ?

A . if x = 2
B . if (x == 12)
C . if x = 12 then
D. if x == 12 then

Q3. Which of the following is a correct for loop

A . for (i = 0; i <= 10; i++)
B . for (i <= 10; i++)
C . for i = 1 to 10
D. for (i = 0; i <= 10)

Q4. Which of the following is a correct javascript comment

A . //This is a javascript comment
B . <!--This is a javascript comment -->
C . /* This is javascript comment
D. 'This is a javascript comment

Q5. What is the HTML tag for start of javascript code

A . <js>
B . <javascript>
C . <java>
D. <script>

Q6. How do you write "Hello World" in javascript?

A . document.write("Hello World")
B . print "Hello World"
C . ("Hello World")
D. "Hello World"

Q7. Consider the following for loop

    var x = 4 ;
    for (i=0; i<=2; i++)
	{
	  x = x+3;
	}

What is the value of x at the end of for loop.


A . 5
B . 8
C . 13
D. 11

Q8. What is the correct place to insert javascript

A . The <body> section
B . The <head> section
C . Both <body> section and the <head> section are ok
D. Neither <body> section nor the <head> section - they should be in a separate file

Q9. Consider the following code in Javascript, which tries to calculate and print area of a rectangle.
var length = 20 ;
width = 10 ;
var area = length * width;
document.write(" Area of rectangle is ", Area);
Which line has error ?


A . var length = 20 ;
B . width = 10 ;
C . var area = length * width;
D. document.write(" Area of rectangle is ", Area);

Q10. Consider the following while loop

    var i = 2 ;
    while (i<=10)
	{
	  i = i+3;
	}

What is the value of i at the end of while statement.


A . 5
B . 8
C . 13
D. 11


Try other quizzes

Quiz 1

Quiz 2

Quiz 3