wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Conditionals in JavaScript

Total questions: 14

Worksheet time: 7mins

Name
Class
Date
1.

What checks a specific condition and performs a task based on the condition?

a)

switch statements

b)

operators

c)

console.log

d)

conditional statements

2.

What will print to the console?

a)

Time to buy!

b)

Time to wait for a sale.

c)

sale

d)

Nothing, there is a syntax error on the fourth line

3.

What will print to the console?

a)

Time to buy!

b)

Time to wait for a sale.

c)

sale

d)

Nothing, there is a syntax error on the fourth line

4.

Choose the correct syntax for the strict identity operator.

a)

=

b)

==

c)

===

d)

====

5.

Boolean is the name for a true/false value.

a)

True

b)

False

6.

Which correctly matches the logical operator with its syntax?

a)

and - !

or - | |

not - &&

b)

and - &&

or - | |

not - !

c)

and - | |

or - !

not - &&

d)

and - &&

or - !

not - | |

7.

For this conditional to be true....

a)

day must be equal to Saturday and Sunday

b)

day must be not equal to Saturday or Sunday

c)

day must be equal to Saturday or Sunday

8.

Which operator essentially takes a true value and passes back false, or takes a false value and passes back true.

a)

&&

b)

| |

c)

!

d)

??

9.

Which is NOT an example of a falsy value?

a)

0

b)

NaN

c)

empty strings

d)

null

e)

defined

10.

What will print to the console?

a)

Let us eat apples!

b)

No apples left!

c)

nothing, there is a syntax error because the if statement doesn't have a comparison operator

d)

0

11.

In a JavaScript boolean condition, what is the name for the shorter way of assigning the truthy value to a variable if you use the || operator in your assignment?

a)

shorty evaluation

b)

short-circuit evaluation

c)

truthy evaluation

d)

falsy evaluation

12.

The if-else statement in the top image and the ternary operator in the lower image will result in the same output being logged to the console.

a)

True

b)

False

13.

Else-if statements only allow for two possible outcomes.

a)

True

b)

False

14.

What syntax provides an alternative and simpler way to create a conditional with a large number of else-if statements?

a)

else-if-else statement

b)

switch statement

c)

case statement

d)

break statement