JavaScript Basics Quiz

Create an account and save your quiz results

Login and save your results

OR

Question 1/15

What does "NaN" stand for in JavaScript?

Select your answer

Question 2/15

What will the value of "x" be after the code is run?
let x = 5;
x = x * 2;

Select your answer

Question 3/15

How can you add a comment in JavaScript?

Select your answer

Question 4/15

In JavaScript, what will '2' + 2 evaluate to?

Select your answer

Question 5/15

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

Select your answer

Question 6/15

What is a typical use case for the "isNaN()" function?

Select your answer

Question 7/15

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

Select your answer

Question 8/15

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

Select your answer

Question 9/15

How do you write an "if" statement in JavaScript to execute some code if "i" is equal to 5?
if (i === 5) {
    // code to execute
}

Select your answer

Question 10/15

How do you create a function in JavaScript?
function myFunction() {
    // code here
}

Select your answer

Question 11/15

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

Select your answer

Question 12/15

What is the correct way to declare a variable in JavaScript?

Select your answer

Question 13/15

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

Select your answer

Question 14/15

What is the correct syntax for referring to an external JavaScript file called 'app.js'?

Select your answer

Question 15/15

What method is used to add new elements to the end of an array?

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
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 2/15
😊 Your answer was correct 🙁 Your answer was incorrect
What will the value of "x" be after the code is run?
let x = 5;
x = x * 2;

Available answers

The operation
x = x * 2
assigns the result of
5 * 2
to
x
, which is
10
.
Question 3/15
😊 Your answer was correct 🙁 Your answer was incorrect
How can you add a comment in JavaScript?

Available answers

In JavaScript, comments start with
//
for single-line comments or
/* ... */
for multi-line comments.
Question 4/15
😊 Your answer was correct 🙁 Your answer was incorrect
In JavaScript, what will '2' + 2 evaluate to?

Available answers

In JavaScript, the expression
'2' + 2
results in the string '22' due to string concatenation.
Question 5/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 6/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is a typical use case for the "isNaN()" function?

Available answers

The
isNaN()
function checks if a value is NaN (Not-a-Number).
Question 7/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 8/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 9/15
😊 Your answer was correct 🙁 Your answer was incorrect
How do you write an "if" statement in JavaScript to execute some code if "i" is equal to 5?
if (i === 5) {
    // code to execute
}

Available answers

The syntax for an "if" statement in JavaScript to check for equality is:
if (i === 5) { /* code */ }
.
Question 10/15
😊 Your answer was correct 🙁 Your answer was incorrect
How do you create a function in JavaScript?
function myFunction() {
    // code here
}

Available answers

To define a function in JavaScript, use the syntax:
function myFunction() { /* code */ }
.
Question 11/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 12/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the correct way to declare a variable in JavaScript?

Available answers

In JavaScript, you declare a variable using the
var
,
let
, or
const
keyword, such as
var myVariable;
.
Question 13/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.
Question 14/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the correct syntax for referring to an external JavaScript file called 'app.js'?

Available answers

To include an external JavaScript file, you use the
<script src='app.js'></script>
syntax.
Question 15/15
😊 Your answer was correct 🙁 Your answer was incorrect
What method is used to add new elements to the end of an array?

Available answers

The
push()
method adds one or more elements to the end of an array.