Menu
HTML CSS
JavaScript Quiz Results
Score: 25 of 25
100% Correct:
Question 1:
Inside which HTML element do we put the JavaScript?
<script> Your answer
<scripting>
<js>
<javascript>
Question 2:
What is the correct JavaScript syntax to change the content of the HTML element below?
<p id="demo">This is a demonstration.</p>
[Link]("demo").innerHTML = "Hello Your answer
World!";
[Link]("p").innerHTML = "Hello World!";
#[Link] = "Hello World!";
[Link]("p").innerHTML = "Hello World!";
Question 3:
Where is the correct place to insert a JavaScript?
Both the <head> section and the <body> section are Your answer
correct
The <head> section
The <body> section
Question 4:
What is the correct syntax for referring to an external script called "[Link]"?
<script src="[Link]"> Your answer
<script name="[Link]">
<script href="[Link]">
Question 5:
The external JavaScript file must contain the <script> tag.
False Your answer
True
Question 6:
How do you write "Hello World" in an alert box?
alert("Hello World"); Your answer
alertBox("Hello World");
msg("Hello World");
msgBox("Hello World");
Question 7:
How do you create a function in JavaScript?
function myFunction() Your answer
function:myFunction()
function = myFunction()
Question 8:
How do you call a function named "myFunction"?
myFunction() Your answer
call function myFunction()
call myFunction()
Question 9:
How to write an IF statement in JavaScript?
if (i == 5) Your answer
if i == 5 then
if i = 5 then
if i = 5
Question 10:
How to write an IF statement for executing some code if "i" is NOT equal to 5?
if (i != 5) Your answer
if i =! 5 then
if i <> 5
if (i <> 5)
Question 11:
How does a WHILE loop start?
while (i <= 10) Your answer
while i = 1 to 10
while (i <= 10; i++)
Question 12:
How does a FOR loop start?
for (i = 0; i <= 5; i++) Your answer
for i = 1 to 5
for (i = 0; i <= 5)
for (i <= 5; i++)
Question 13:
How can you add a comment in a JavaScript?
//This is a comment Your answer
'This is a comment
<!--This is a comment-->
Question 14:
How to insert a comment that has more than one line?
/*This comment has Your answer
more than one line*/
<!--This comment has
more than one line-->
//This comment has
more than one line//
Question 15:
What is the correct way to write a JavaScript array?
var colors = ["red", "green", "blue"] Your answer
var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")
var colors = "red", "green", "blue"
var colors = (1:"red", 2:"green", 3:"blue")
Question 16:
How do you round the number 7.25, to the nearest integer?
[Link](7.25) Your answer
rnd(7.25)
[Link](7.25)
round(7.25)
Question 17:
How do you find the number with the highest value of x and y?
[Link](x, y) Your answer
ceil(x, y)
[Link](x, y)
top(x, y)
Question 18:
What is the correct JavaScript syntax for opening a new window called "w2" ?
w2 = [Link]("[Link] Your answer
w2 = [Link]("[Link]
Question 19:
JavaScript is the same as Java.
False Your answer
True
Question 20:
How can you detect the client's browser name?
[Link] Your answer
[Link]
[Link]
Question 21:
Which event occurs when the user clicks on an HTML element?
onclick Your answer
onmouseclick
onchange
onmouseover
Question 22:
How do you declare a JavaScript variable?
var carName; Your answer
variable carName;
v carName;
Question 23:
Which operator is used to assign a value to a variable?
= Your answer
x
Question 24:
What will the following code return: Boolean(10 > 9)
true Your answer
NaN
false
Question 25:
Is JavaScript case-sensitive?
Yes Your answer
No
Study JavaScript in our JavaScript Tutorial
Kickstart your career
Get certified by completing a
course
Get certified
w3schoo
l
s
CE
RT
1
I
20
2
FI
ED
.
COLOR PICKER
LIKE US
Get certified
by completing
a course today!
school
w3 s
1
CE
02
TI 2
R
FI .
ED
Get started
CODE GAME
Play Game
Report Error
Forum
About
Shop
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference
Top Examples
HTML Examples
CSS Examples
JavaScript Examples
How To Examples
SQL Examples
Python Examples
[Link] Examples
Bootstrap Examples
PHP Examples
Java Examples
XML Examples
jQuery Examples
Web Courses
HTML Course
CSS Course
JavaScript Course
Front End Course
SQL Course
Python Course
PHP Course
jQuery Course
Java Course
C++ Course
C# Course
XML Course
Get Certified »
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot
warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our
terms of use, cookie and privacy policy.
Copyright 1999-2021 by Refsnes Data. All Rights Reserved.
W3Schools is Powered by [Link].