Home » Quiz & Trivia » JavaScript » JavaScript Quiz with answers – Part 2

JavaScript Quiz with answers – Part 2

Practical questions to test your knowledge of JavaScript programming – Part 2

How to insert a comment on several lines?
// This comment has more
than one line //

/* This comment has more
than one line */

All the answers are true

Correct!

Wrong!

How do you find the number with the greatest value of "a" and "b"?
Math.ceil(a, b)
Math.max(a, b)
ceil(a, b)
top(a, b)

Correct!

Wrong!

How can you add a comment in a JavaScript code?
// This is a comment
"Ceci est un commentaire"
#This is a comment

Correct!

Wrong!

JavaScript is identical to Java?
True
False

Correct!

Wrong!

How to round the number 3.12 to a closer whole number?
Math.round(3.12)
Math.rnd(3.12)
float(3.12)
Math.float(3.12)

Correct!

Wrong!

What is the correct syntax for the while loop?
while (i <= 5)
while i = 1 to 5
while (i <= 5; i++)
while (i=0; i <= 5; i++)

Correct!

Wrong!

What is the correct syntax of the for loop?
for (i <= 10; i++)
for i = 1 to 10
for (i = 0; i <= 10)
for (i = 0; i <= 10; i++)

Correct!

Wrong!

What is the correct syntax for opening a new window called "f2"?
f2 = window.new("https://google.com");
f2 = window.open("https://google.com");
f2 = document.open("https://google.com");

Correct!

Wrong!

What is the correct way to write an array in JavaScript?
var fruits = 1 = ("orange"), 2 = ("banana"), 3 = ("apple")
var fruits = (1:"orange", 2:"banana", 3:"apple")
var fruits = "orange", "banana", "apple"
var fruits = ["orange", "banana", "apple"]

Correct!

Wrong!

Share the quiz to show your results !

Subscribe to see your results

JavaScript Quiz – Part 2

I got %%score%% of %%total%% right

%%description%%

%%description%%

Loading...

Leave a Reply

Your email address will not be published. Required fields are marked *

*

x

Check Also

Best Linux distribution

What are the best Linux distributions ?

Linux is a very open system, allowing anyone to inspect and modify its code. That’s ...