Quiz 2 Java Script
Quiz 2 Java Script
JavaScript
Date: 06-09-14
CGS3066: Web Programming and Design
Summer 2014
Duration: 30 minutes Total: 30
Answer all questions. Each MCQ is worth 1 point. For other question, it is written after
each question.
1. When a user views a page containing a JavaScript program, which machine actually executes
the script?
A. The User's machine running a Web browser
B. The Web server
C. A central machine deep within Netscape's corporate offices
D. None of the above
2. Which of the following syntax is correct to refer an external script called “formValidation.js”?
A. <script href = “formValidation.js”>
B. <script source = “formValidation.js”>
C. <script name = “formValidation.js”>
D. <script src = “formValidation.js”>
3. Which of the following is the correct way for writing Java Script array?
A. var salaries = new Array(1:39438, 2:39839 3:83729)
B. var salaries = new (Array1=39438, Array 2=39839 Array 3=83729)
C. var salaries = new Array(39438, 39839,83729)
D. var salaries = new Array() values = 39438, 39839 83729
4. If para1 is the DOM object for a paragraph, what is the correct syntax to change the text
within the paragraph?
A. "New Text"?
B. para1.value="New Text";
C. para1.firstChild.nodeValue= "New Text";
D. para1.nodeValue="New Text";
13. Write a function called insertText that inserts the string “Welcome to my site!” into an
element with Id “para1”. 4
14. Write a function called changeBGColor that changes the background color of all elements
which has Class name “classColor”. 4