JAVASCRIPT QUIZ WITH COMPLETE
SOLUTIONS
1.Inside which HTML element do we put the JavaScript?
a) <javascript>
b) <js>
c) <script>
d) <scripting> - Correct Answers -c) <script>
2. What is the correct JavaScript syntax to write "Hello World"?
a) response.write("Hello World")
b) "Hello World"
c) document.write("Hello World")
d) ("Hello World") - Correct Answers -c) document.write("Hello World")
3. Where is the correct place to insert a JavaScript?
a) Both the <head> section and the <body> section are correct
b) The <body> section
c) The <head> section - Correct Answers -a) Both the <head> section and the <body>
section are correct
4. What is the correct syntax for referring to an external script called "xxx.js"?
a) <script src="xxx.js">
b) <script name="xxx.js">
c) <script href="xxx.js">
d) <script value="xxx.js"> - Correct Answers -a) <script src="xxx.js">
5. An external JavaScript must contain the <script> tag
a) False
b) True - Correct Answers -a) False
6. How do you write "Hello World" in an alert box?
a) alert("Hello World")
b) msgBox("Hello World")
c) alertBox="Hello World"
d) alertBox("Hello World") - Correct Answers -a) alert("Hello World")
7. How do you create a function?
a) function:myFunction()
, b) function=myFunction()
c) function myFunction()
d) myFunction():function - Correct Answers -c) function myFunction()
38. In JavaScript, what would be the proper form of address in the object hierarchy for
the second element in a form called "info"?
a) document.info.elements[1]
b) document.info.elements[2]
c) document.forms.info.elements[2]
d) info.elements[2] - Correct Answers -a) document.info.elements[1]
39. A named element in a JavaScript program that is used to store and retrieve data is a
_____.
a) Method
b) assignment operator
c) Variable
d) string - Correct Answers -c) Variable
40. Which of the following is not true
a) CSS is tightly integrated with the HTML structure.
b) CSS is part of dynamic HTML.
c) CSS stand for cascading style sheet.
d) CSS is for design control of the Web page appearance. - Correct Answers -a) CSS is
tightly integrated with the HTML structure.
8. How do you call a function named "myFunction"?
a) call myFunction()
b) myFunction()
c) call function myFunction
d) Call.myFunction() - Correct Answers -b) myFunction()
9. How do you write a conditional statement for executing some statements only if "i" is
equal to 5?
a) if i==5 then
b) if (i==5)
c) if i=5 then
d) if i=5 - Correct Answers -b) if (i==5)
10. How do you write a conditional statement for executing some statements only if "i" is
NOT equal to 5?
a) if (i != 5)
b) if =! 5 then
c) if (i <> 5)
d) if <>5 - Correct Answers -a) if (i != 5)
11. How many looping statements are there in JavaScript?
a) 2. The "for" loop, and the "while" loop
SOLUTIONS
1.Inside which HTML element do we put the JavaScript?
a) <javascript>
b) <js>
c) <script>
d) <scripting> - Correct Answers -c) <script>
2. What is the correct JavaScript syntax to write "Hello World"?
a) response.write("Hello World")
b) "Hello World"
c) document.write("Hello World")
d) ("Hello World") - Correct Answers -c) document.write("Hello World")
3. Where is the correct place to insert a JavaScript?
a) Both the <head> section and the <body> section are correct
b) The <body> section
c) The <head> section - Correct Answers -a) Both the <head> section and the <body>
section are correct
4. What is the correct syntax for referring to an external script called "xxx.js"?
a) <script src="xxx.js">
b) <script name="xxx.js">
c) <script href="xxx.js">
d) <script value="xxx.js"> - Correct Answers -a) <script src="xxx.js">
5. An external JavaScript must contain the <script> tag
a) False
b) True - Correct Answers -a) False
6. How do you write "Hello World" in an alert box?
a) alert("Hello World")
b) msgBox("Hello World")
c) alertBox="Hello World"
d) alertBox("Hello World") - Correct Answers -a) alert("Hello World")
7. How do you create a function?
a) function:myFunction()
, b) function=myFunction()
c) function myFunction()
d) myFunction():function - Correct Answers -c) function myFunction()
38. In JavaScript, what would be the proper form of address in the object hierarchy for
the second element in a form called "info"?
a) document.info.elements[1]
b) document.info.elements[2]
c) document.forms.info.elements[2]
d) info.elements[2] - Correct Answers -a) document.info.elements[1]
39. A named element in a JavaScript program that is used to store and retrieve data is a
_____.
a) Method
b) assignment operator
c) Variable
d) string - Correct Answers -c) Variable
40. Which of the following is not true
a) CSS is tightly integrated with the HTML structure.
b) CSS is part of dynamic HTML.
c) CSS stand for cascading style sheet.
d) CSS is for design control of the Web page appearance. - Correct Answers -a) CSS is
tightly integrated with the HTML structure.
8. How do you call a function named "myFunction"?
a) call myFunction()
b) myFunction()
c) call function myFunction
d) Call.myFunction() - Correct Answers -b) myFunction()
9. How do you write a conditional statement for executing some statements only if "i" is
equal to 5?
a) if i==5 then
b) if (i==5)
c) if i=5 then
d) if i=5 - Correct Answers -b) if (i==5)
10. How do you write a conditional statement for executing some statements only if "i" is
NOT equal to 5?
a) if (i != 5)
b) if =! 5 then
c) if (i <> 5)
d) if <>5 - Correct Answers -a) if (i != 5)
11. How many looping statements are there in JavaScript?
a) 2. The "for" loop, and the "while" loop