Search Header Logo

JavaScript Conditionals Quiz

Authored by Andell Haughton

Computers

12th Grade

Used 30+ times

JavaScript Conditionals Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

32 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax for an if statement in JavaScript?

if (x > 0) { }

if x > 0: { }

if x > 0 then { }

if (x > 0) then { }

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which logical operator is used in JavaScript to represent "AND"?

&&

||

!

==

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output? ```javascript if (false || true) { console.log("True"); } else { console.log("False"); } ```

True

False

Error

Nothing

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you write an if statement in JavaScript to execute some code if "x" is either greater than 10 or less than or equal to 20?

if (x > 10 || x <= 20)

if (x > 10 && x <= 20)

if x > 10 or x <= 20

if x > 10 and x <= 20

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code snippet? ```javascript let x = 5; if (x > 3) { if (x < 10) { console.log("Yes"); } } else { console.log("No"); } ```

Yes

No

Error

Nothing

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following JavaScript code output? ```javascript let age = 18; if (age > 18) { console.log("Adult"); } else if (age == 18) { console.log("Just an adult"); } else { console.log("Not an adult"); } ```

Adult

Just an adult

Not an adult

Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In JavaScript, which logical operator represents the "OR" condition?

&&

||

!

==

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?