WorksheetsBoolean Logic, Comparison Operators, and Loops Review Quiz
Total questions: 20
Worksheet time: 11mins
Complete the statement: The else block in an if-else statement is executed when ______.
A) All conditions are true
B) No conditions are true
C) The first condition is true
D) The last condition is true
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?
When she has filled 5 bottles
When she has filled 4 bottles
When she has filled 6 bottles
When she has filled 3 bottles
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?
true
false
undefined
an error
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?
She will go for a walk
She will not go for a walk
undefined
an error
What is the output of the following code? let i = 0;
while (i < 4) {
console.log(i);
i++;
}
A) 0 1 2 3
B) 1 2 3 4
C) 0 1 2 3 4
D) 2 3 4 5
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.
Repeat a block of code a specific number of times
Execute code only once
Check conditions
Handle exceptions
What is the output of the following code? let i = 0;
while (i < 3) {
console.log(i);
i++;
}
A) 0 1 2
B) 1 2 3
C) 0 1 2 3
D) 2 3 4
What is the output of the following JavaScript code? let x = 10; console.log(x != 10);
true
false
10
error
What is the purpose of an else statement?
A) To execute code only if the condition is true
B) To execute code only if the condition is false
C) To break out of a loop
D) To restart the program
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");
}
Less
Equal
More
Error
What is the result of !(true)?
true
false
null
undefined
What will the following code output?
let x = 5;
if (x > 10) {
console.log("Greater");
} else {
console.log("Smaller");
}
Greater
Smaller
Error
Nothing
Boolean
A single value of either TRUE or FALSE
Any valid unit of code that resolves to a value.
Part of a program that does not work correctly.
What does continue do in a loop?
Skips the current iteration and continues with the next
Exits the loop immediately
Stops the loop
Restarts the loop
How does the break statement work?
A) It exits the loop immediately
B) It skips the current iteration
C) It continues to the next iteration
D) It does nothing
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?
true
false
5
8
Fill in the blank: The break statement is used to ____.
Exit the loop immediately
Skip the current iteration
Continue to the next iteration
Restart the loop
Fill in the blank: The increment part of a for loop is used to ____.
Increase the loop variable
Decrease the loop variable
Check the condition
Execute the loop body
Fill in the blank: In JavaScript, the expression 5 > 3 && 8 < 10 evaluates to ____.
true
false
5
8
What will be the output of the following code? let i = 0;
while (i < 2) {
console.log(i);
i++;
}
A) 0 1
B) 1 2
C) 0 1 2
D) 2 3
