JavaScript Basics Quiz

Create an account and save your quiz results

Login and save your results

OR

Question 1/15

Which operator is used to assign a value to a variable?

Select your answer

Question 2/15

What will the following code output?
var fruits = ['Apple', 'Banana', 'Mango'];
console.log(fruits[1]);

Select your answer

Question 3/15

What does the "alert()" function do in JavaScript?

Select your answer

Question 4/15

Which method can be used to convert a JSON string into a JavaScript object?

Select your answer

Question 5/15

What does "const" declare in JavaScript?

Select your answer

Question 6/15

How do you find the number with the highest value of x and y?
Math.max(x, y);

Select your answer

Question 7/15

What does "NaN" stand for in JavaScript?

Select your answer

Question 8/15

Which of these is not a reserved word in JavaScript?

Select your answer

Question 9/15

When the following code is executed, what will the value of the expression be?
3 == '3'

Select your answer

Question 10/15

What is the output when you execute the following code?
console.log(typeof 42);

Select your answer

Question 11/15

Which of the following will write "Hello World!" to the console?

Select your answer

Question 12/15

Which of the following is a string method in JavaScript?

Select your answer

Question 13/15

How do you round 7.25 to the nearest integer in JavaScript?
Math.round(7.25);

Select your answer

Question 14/15

What is the output of the following JavaScript code?
var x = 10;
x += 5;
console.log(x);

Select your answer

Question 15/15

What will the following expression return: Boolean(0);
Boolean(0);

Select your answer

Your Results

You did not answer any questions correctly.

Your Answers

Question 1/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which operator is used to assign a value to a variable?

Available answers

The assignment operator in JavaScript is
=
, used to assign values to variables.
Question 2/15
😊 Your answer was correct 🙁 Your answer was incorrect
What will the following code output?
var fruits = ['Apple', 'Banana', 'Mango'];
console.log(fruits[1]);

Available answers

Arrays in JavaScript are zero-indexed, so
fruits[1]
contains
'Banana'
.
Question 3/15
😊 Your answer was correct 🙁 Your answer was incorrect
What does the "alert()" function do in JavaScript?

Available answers

The
alert()
function displays an alert box containing a specified message and an OK button.
Question 4/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which method can be used to convert a JSON string into a JavaScript object?

Available answers

The
JSON.parse()
method is used to convert a JSON string into a JavaScript object.
Question 5/15
😊 Your answer was correct 🙁 Your answer was incorrect
What does "const" declare in JavaScript?

Available answers

const
declares a variable that is read-only after initialization, meaning it cannot be reassigned.
Question 6/15
😊 Your answer was correct 🙁 Your answer was incorrect
How do you find the number with the highest value of x and y?
Math.max(x, y);

Available answers

The function
Math.max()
is used to find the highest value among its parameters.
Question 7/15
😊 Your answer was correct 🙁 Your answer was incorrect
What does "NaN" stand for in JavaScript?

Available answers

NaN
stands for "Not-a-Number", indicating a value that is not a legal number.
Question 8/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which of these is not a reserved word in JavaScript?

Available answers

The word
program
is not a reserved keyword in JavaScript, unlike
switch, throw, default
.
Question 9/15
😊 Your answer was correct 🙁 Your answer was incorrect
When the following code is executed, what will the value of the expression be?
3 == '3'

Available answers

The
==
operator checks for equality with type coercion. Hence
3 == '3'
is
true
.
Question 10/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the output when you execute the following code?
console.log(typeof 42);

Available answers

The
typeof
operator returns
'number'
for numerical literals like
42
.
Question 11/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which of the following will write "Hello World!" to the console?

Available answers

The function
console.log()
is used to output messages to the web console in JavaScript.
Question 12/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which of the following is a string method in JavaScript?

Available answers

The
toUpperCase()
method converts a string to uppercase letters.
Question 13/15
😊 Your answer was correct 🙁 Your answer was incorrect
How do you round 7.25 to the nearest integer in JavaScript?
Math.round(7.25);

Available answers

To round a number in JavaScript, use
Math.round()
.
Question 14/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the output of the following JavaScript code?
var x = 10;
x += 5;
console.log(x);

Available answers

The code uses
+=
to add
5
to
x
, giving
15
.
Question 15/15
😊 Your answer was correct 🙁 Your answer was incorrect
What will the following expression return: Boolean(0);
Boolean(0);

Available answers

The expression
Boolean(0)
returns
false
because
0
is considered a "falsy" value in JavaScript.