Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
121 views

Quiz 2 Java Script

JAva Script Quiz

Uploaded by

shagufta.shaikh1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

Quiz 2 Java Script

JAva Script Quiz

Uploaded by

shagufta.shaikh1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Quiz#2

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";

5. JavaScript is interpreted by _________


A. Client
B. Server
C. Object
D. None of the above

6. Using _______ statement is how you test for a specific condition.


A. Select
B. If
C. Switch
D. For
7. How do you write "Hello World" in an alert box?
A. alertBox("Hello World");
B. msgBox("Hello World");
C. msg("Hello World");
D. alert("Hello World");

8. How do you create a function in JavaScript?


A. function:myFunction()
B. function myFunction()
C.function = myFunction()

9.How does a FOR loop start?


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

10. How can you add a comment in a JavaScript?


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

11. JavaScript is the same as Java.


A. Flase
B. True

12. What JavaScript keyword declares a variable?


A. var
B. if
C. for
D. create

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

15. Consider the following code segment-


<form>
Enter User Id: <input type =”text” name=”userid” id=”userid”>
<input type=”button” value=”Check User ID” onclick=”return chekID();”>
</form>
Write JavaScript code for chekcID() function, which checks the value entered userid field and
return true if it contains only alphabet(A-Za-Z)/number(0-9)/_(underscore) otherwise return
false. You may consider defining a regular expression(pattern) while implementing the function.
10

You might also like