wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Control Structures Review

Total questions: 10

Worksheet time: 15mins

Name
Class
Date
1.

What is the syntax for an if-else statement in JavaScript?

4 lines
2.

How many times will a for loop iterate if the condition is 'i < 5' and the initial value of i is 0?

a)

5

b)

1

c)

0

d)

2

3.

What is the purpose of a while loop in JavaScript?

a)

To skip a block of code

b)

To execute a block of code only once

c)

To repeatedly execute a block of code as long as a specified condition is true.

d)

To terminate the execution of a loop

4.

Which logical operator is used to combine two or more conditions and returns true if all conditions are true?

a)

OR

b)

NOT

c)

XOR

d)

AND

5.

What is the output of the following code? var x = 5; var y = 10; if (x > y) { console.log('x is greater than y'); } else if (x < y) { console.log('x is less than y'); } else { console.log('x is equal to y'); }

4 lines
6.

What is the syntax for a for loop in JavaScript?

4 lines
7.

What is the purpose of an if-else statement in JavaScript?

a)

To define a function in JavaScript

b)

To repeat a code block multiple times

c)

To assign a value to a variable in JavaScript

d)

To execute different code blocks based on a condition

8.

Which logical operator is used to combine two or more conditions and returns true if at least one condition is true?

a)

OR

b)

AND

c)

XOR

d)

NOT

9.

What is the output of the following code? var i = 0; while (i < 5) { console.log(i); i++; }

4 lines
10.

What is the purpose of a conditional operator in JavaScript?

a)

The purpose of a conditional operator in JavaScript is to perform different actions based on different conditions.

b)

The purpose of a conditional operator in JavaScript is to execute a block of code repeatedly.

c)

The purpose of a conditional operator in JavaScript is to define a function.

d)

The purpose of a conditional operator in JavaScript is to perform mathematical calculations.