wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz # 5 (Second Quarter)

Total questions: 20

Worksheet time: 8mins

Name
Class
Date
1.

What is the main purpose of a for loop in JavaScript?

a)

To check conditions only

b)

To repeat a block of code multiple times

c)

To store multiple values in a one variable

d)

To stop the execution of a program

2.

It decides how long the loop will run in a for loop.

a)

Initialization

b)

Declaration

c)

Condition

d)

Update

3.

This is where you set up the loop's starting point. You typically declare and assign a value to a counter variable.

a)

Initialization

b)

Condition

c)

Update

d)

Execution

4.

A condition usually runs with this operators.

a)

Arithmetic Operators

b)

Assignment Operators

c)

Logical Operators

d)

Comparison Operators

5.

This part of the expression modifies the counter variable after each loop iteration. It add or deduct value.

a)

Update

b)

Condition

c)

Initialization

d)

Declaration

6.

Which refers to a collection of data, or an ordered list of values, where each value can be of any data type.

a)

For Loop

b)

Expression

c)

Array

d)

Variable

7.

Which is a numerical value that identifies the position of a specific element within the array.

a)

Drawer

b)

Array

c)

Index

d)

Value

8.

Which statement is best for exiting a loop prematurely?

a)

continue

b)

break

c)

stop

d)

return

9.

Which operator increases a variable after using its current value?

a)

++i

b)

--i

c)

i--

d)

i++

10.

Which operator decreases a variable by 2 after using its current value?

a)

i += 2;

b)

i -= 2;

c)

i = 2 + 1;

d)

i = i + i;

11.

Which control flow structure is best for handling multiple distinct options?

a)

if statement

b)

for loop

c)

if else statement

d)

switch statement

12.

Which loop is best for iterating over array elements?

a)

if

b)

for

c)

while

d)

do.. while

13.

LOOK AT THE IMAGE
If a programmer wants to print the colors in reverse:
Which loop setup is correct?

a)

for (let i = 0; i < colors.length; i++)

b)

for (let i = colors.length; i > 0; i--)

c)

for (let i = colors.length - 1; i >= 0; i--)

d)

for (let i = 1; i <= colors.length; i++)

14.

LOOK AT THE IMAGE
Which change will make this loop stop after printing numbers 1 to 10?

a)

Change < to <=

b)

Change i++ to i--

c)

Change starting value to 0

d)

Remove the condition

15.

A school uses a loop to record 30 students’ attendance.
If a student arrives between 8:00–8:14 AM, the system marks “Late.”
What control flow structure best fits this logic?

a)

for loop only

b)

if-else if inside a for loop

c)

A single if statement

d)

A while loop

16.

LOOK AT THE IMAGE
What is the output of this code?

a)

Apple+Banana+Mango

b)

Mango Banana Apple

c)

AppleBananaMango

d)

Apple Banana Mango

17.

Why does JavaScript array indexing start at 0 instead of 1?

a)

To confuse beginners, since we learned to count starting with 1 not 0.

b)

To save memory and space on our storage devices.

c)

Because of how memory addresses work and efficiency in computing

d)

Because it’s required by HTML, and that is how it was made by the developers

18.

LOOK AT THE IMAGE
In a traffic light simulation using arrays and loops:
Which loop statement would correctly cycle through each light once?

a)

for (let i = 1; i < 3; i++)

b)

for (let i = 0; i <= 3; i++)

c)

for (let i = 1; i <= lights.length; i++)

d)

for (let i = 0; i < lights.length; i++)

19.

If brushing your teeth daily is like a loop, what represents the loop condition?

a)

The act of brushing your teeth

b)

The toothbrush that you used and change after a month

c)

The moment you stop brushing when your teeth are clean

d)

The toothpaste used depend on the brand

20.

LOOK AT THE IMAGE
What will happen when this code runs?

a)

It will print 1 to 5 correctly

b)

It will not print anything

c)

It will cause an infinite loop

d)

It will throw a syntax error