Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Boolean Logic, Comparison Operators, and Loops Review Quiz

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

Complete the statement: The else block in an if-else statement is executed when ______.

a)

A) All conditions are true

b)

B) No conditions are true

c)

C) The first condition is true

d)

D) The last condition is true

2.

Anika is filling water bottles. She starts with 0 bottles and continues to fill one bottle at a time until she has filled 5 bottles. When does she stop filling bottles?

a)

When she has filled 5 bottles

b)

When she has filled 4 bottles

c)

When she has filled 6 bottles

d)

When she has filled 3 bottles

3.

Michael and Harper are planning a picnic. They will go only if both the weather is sunny and they both have a day off. What does the && (AND) operator return when both conditions are true?

a)

true

b)

false

c)

undefined

d)

an error

4.

Zoe is deciding whether to go for a walk. She will only go if it is sunny and not raining. What is the result of it being sunny && raining?

a)

She will go for a walk

b)

She will not go for a walk

c)

undefined

d)

an error

5.

What is the output of the following code? let i = 0;

while (i < 4) {

console.log(i);

i++;

}

a)

A) 0 1 2 3

b)

B) 1 2 3 4

c)

C) 0 1 2 3 4

d)

D) 2 3 4 5

6.

Fill in the blank: Henry uses a for loop to ____ when he wants to practice his guitar scales a specific number of times each day.

a)

Repeat a block of code a specific number of times

b)

Execute code only once

c)

Check conditions

d)

Handle exceptions

7.

What is the output of the following code? let i = 0;

while (i < 3) {

console.log(i);

i++;

}

a)

A) 0 1 2

b)

B) 1 2 3

c)

C) 0 1 2 3

d)

D) 2 3 4

8.

What is the output of the following JavaScript code? let x = 10; console.log(x != 10);

a)

true

b)

false

c)

10

d)

error

9.

What is the purpose of an else statement?

a)

A) To execute code only if the condition is true

b)

B) To execute code only if the condition is false

c)

C) To break out of a loop

d)

D) To restart the program

10.

What is the output of the following code? let num = 5;

if (num < 10) {

console.log("Less");

} else if (num == 10) {

console.log("Equal");

} else {

console.log("More");

}

a)

Less

b)

Equal

c)

More

d)

Error

11.

What is the result of !(true)?

a)

true

b)

false

c)

null

d)

undefined

12.

What will the following code output?

let x = 5;

if (x > 10) {

console.log("Greater");

} else {

console.log("Smaller");

}

a)

Greater

b)

Smaller

c)

Error

d)

Nothing

13.

Boolean

a)

A single value of either TRUE or FALSE

b)

Any valid unit of code that resolves to a value.

c)

Part of a program that does not work correctly.

14.

What does continue do in a loop?

a)

Skips the current iteration and continues with the next

b)

Exits the loop immediately

c)

Stops the loop

d)

Restarts the loop

15.

How does the break statement work?

a)

A) It exits the loop immediately

b)

B) It skips the current iteration

c)

C) It continues to the next iteration

d)

D) It does nothing

16.

Nora has 5 apples and she knows that 5 is greater than 3. She also has 8 oranges and knows that 8 is less than 10. What will console.log(5 > 3 && 8 < 10); print?

a)

true

b)

false

c)

5

d)

8

17.

Fill in the blank: The break statement is used to ____.

a)

Exit the loop immediately

b)

Skip the current iteration

c)

Continue to the next iteration

d)

Restart the loop

18.

Fill in the blank: The increment part of a for loop is used to ____.

a)

Increase the loop variable

b)

Decrease the loop variable

c)

Check the condition

d)

Execute the loop body

19.

Fill in the blank: In JavaScript, the expression 5 > 3 && 8 < 10 evaluates to ____.

a)

true

b)

false

c)

5

d)

8

20.

What will be the output of the following code? let i = 0;

while (i < 2) {

console.log(i);

i++;

}

a)

A) 0 1

b)

B) 1 2

c)

C) 0 1 2

d)

D) 2 3