Home  • Programming • JavaScript

Quiz-1 : JavaScript Basic

1. Which of the following is the correct syntex of "for" loop?

A) for (i = 0; i <= 5; i++;){

B) for (i = 0; i <= 5; i++){

C) for i = 1 to 5

end for
D) for (i <= 5; i++){


2. You work on a JavaScript project. How do you prompt users with messages and at the same time requesting user inputs?

A) alert()
B) display()
C) prompt()
D) input()

3. Which are the correct comparison operators?

A) >=,<=,==,=!
B) >=,<=,==,!=
C) =<,=>,==,=!
D) >=,=<,==,!=

4. How do you call a function named "myFunction"?

A) call function myFunction()
B) myFunction()
C) call myFunction()
D) none

5. What is the correct JavaScript syntax for opening a new window called "window5" ?

A) new("http://www.ex-designz.net","window5")
B) window.open("http://www.ex-designz.net","window5")
C) open.new window("http://www.ex-designz.net","window5")
D) new.window("http://www.ex-designz.net","window5")

6. In some case, which of the following could be replacement for "if"?

A) for
B) while
C) do-while
D) switch-case

7. What is the correct syntax for referring to an external script called "file.js"?

A) <script name="file.js" type=”text/javascript”></script>
B) <script href="file.js" type=”text/javascript” />
C) <script src="file.js" type=”text/javascript”></script>
D) <link src="file.js" type=”text/javascript” />

8. Your company assigns you to work on a JavaScript project. With the DATE object, which of the following allows you to call a function based on an elapsed time?

A) setElapsedTime()
B) Timeout()
C) setTimeout()
D) setTime()

9. What will produce the output of following JavaScript code?

<script type="text/javascript">



A) 19
B) 19.00
C) 910
D) error

10. What is the correct way to write a one dimensional JavaScript array?

A) var txt = new Array(1:"tim",2:"shaq",3:"kobe")
B) var txt = new Array="tim","shaq","kobe"
C) var txt = new Array("tim","shaq","kobe")
D) var txt=["tim","shaq","kobe"]
E) var txt = new Array()

Comments 0


About Author