Quiz
JavaScript 1
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (25)
1Inside which HTML element do we put the JavaScript?
- A<javascript>
- B<script>
- C<js>
- D<scripting>
2What is the correct JavaScript syntax to change the content of the HTML element below?
<p id="demo">This is a demonstration.</p>- Adocument.getElementById("demo").innerHTML = "Hello World!";
- Bdocument.getElement("p").innerHTML = "Hello World!";
- Cdocument.getElementByName("p").innerHTML = "Hello World!";
- D#demo.innerHTML = "Hello World!";
3Where is the correct place to insert a JavaScript?
- AThe <body> section
- BThe <head> section
- CBoth the <head> section and the <body> section are correct
4What is the correct syntax for referring to an external script called "xxx.js"?
- A<script href="xxx.js">
- B<script name="xxx.js">
- C<script src="xxx.js">
5The external JavaScript file must contain the <script> tag.
- ATrue
- BFalse
6How do you write "Hello World" in an alert box?
- AalertBox("Hello World");
- Bmsg("Hello World");
- CmsgBox("Hello World");
- Dalert("Hello World");
7How do you create a function in JavaScript?
- Afunction myFunction()
- Bfunction:myFunction()
- Cfunction = myFunction()
8How do you call a function named "myFunction"?
- Acall function myFunction()
- Bcall myFunction()
- CmyFunction()
9How to write an IF statement in JavaScript?
- Aif i = 5 then
- Bif i = 5
- Cif i == 5 then
- Dif (i == 5)
10How to write an IF statement for executing some code if "i" is NOT equal to 5?
- Aif (i <> 5)
- Bif (i != 5)
- Cif i <> 5
- Dif i =! 5 then
11How does a WHILE loop start?
- Awhile i = 1 to 10
- Bwhile (i <= 10)
- Cwhile (i <= 10; i++)
12How does a FOR loop start?
- Afor i = 1 to 5
- Bfor (i <= 5; i++)
- Cfor (i = 0; i <= 5)
- Dfor (i = 0; i <= 5; i++)
13How can you add a comment in a JavaScript?
- A'This is a comment
- B//This is a comment
- C<!--This is a comment-->
14How to insert a comment that has more than one line?
- A<!--This comment has
more than one line--> - B/*This comment has
more than one line*/ - C//This comment has
more than one line//
- A<!--This comment has
15What is the correct way to write a JavaScript array?
- Avar colors = ["red", "green", "blue"]
- Bvar colors = (1:"red", 2:"green", 3:"blue")
- Cvar colors = "red", "green", "blue"
16How do you round the number 7.25, to the nearest integer?
- AMath.round(7.25)
- BMath.rnd(7.25)
- Cround(7.25)
- Drnd(7.25)
17How do you find the number with the highest value of x and y?
- AMath.ceil(x, y)
- Btop(x, y)
- Cceil(x, y)
- DMath.max(x, y)
18What is the correct JavaScript syntax for opening a new window called "w2" ?
- Aw2 = window.open("http://www.w3schools.com");
- Bw2 = window.new("http://www.w3schools.com");
19JavaScript is the same as Java.
- ATrue
- BFalse
20How can you detect the client's browser name?
- Aclient.navName
- Bbrowser.name
- Cnavigator.appName
21Which event occurs when the user clicks on an HTML element?
- Aonchange
- Bonclick
- Conmouseclick
- Donmouseover
22How do you declare a JavaScript variable?
- Avar carName;
- Bv carName;
- Cvariable carName;
23Which operator is used to assign a value to a variable?
- A-
- B=
- C*
- DX
24What will the following code return: Boolean(10 > 9)
- Atrue
- BNaN
- Cfalse
25Is JavaScript case-sensitive?
- AYes
- BNo
Information
- Description
- Quiz on JavaScript 1, created by Alex Thompson on 08/12/2016.
- Author
- Alex Thompson
- Language
- English
- Views
- 1
- Rating
- No ratings yet Rate this quiz