wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz No. 3 - JS Loops

Total questions: 20

Worksheet time: 14mins

Name
Class
Date
1.

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println("Hi"), it will output: Hi

Consider the following code: var i = 0; while (i < 3) { println("hi"); i++; }

a)

hi hi hi hi

b)

hi hi hi

c)

hi hi

d)

hi

2.

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println("Hi"), it will output: Hi

Consider the following code: var i = 0; while (i < 3) { println("hi"); i++; } println("bye");

a)

hi bye

b)

hi

bye

hi

bye

hi

bye

c)

hi

hi

hi

bye

d)

hi

hi

bye

3.

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println("Hi"), it will output: Hi

Consider the following code:

var i = 0; while (i < 0) { println("hi"); }

a)

hi

b)

it won't output anything

c)

it will output an error

d)

hi hi

4.

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println(10), it will output: 10

Consider the following code: var x = 3; var i = 0; while (i < 3) { x += 1; i += 1; } println(x);

a)

3

b)

6

c)

7

d)

4

5.

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println(10), it will output: 10

Consider the following code:

var i = 3; while (i < 6) { println(i); i += 1; }

a)

1

2

3

b)

4

5

6

c)

3

4

5

d)

3

4

5

6

6.

Note: the println() function prints out a line of text with the value that you pass to it - so if you say println(10), it will output: 10

Consider the following code:

var i = 0; while (i < 3) { println(i); i++; }

a)

1

2

3

b)

0

1

2

3

c)

1

2

3

4

d)

0

1

2

7.

Consider the following code:

let i; (i = 0; i<10; i++ ) { console.log(i); }

a)

It creates a loop that runs from 0 to 9

b)

It creates a loop that runs from 1 to 9

c)

It creates a loop that runs from 9 to 0

d)

It creates a loop that runs from 9 to 1

8.

The number is 0

The number is 1

The number is 2

The number is 3

The number is 4

which is the correct code?

a)

for (i = 0; i < 5 i++)

b)

FOR (i = 0; i < 5; i++)

c)

for (i = 0; i < 4; i++)

d)

for (i = 0; i < 5; i++)

9.

what is a while loop?

a)

loops through a block of code as long as a specified condition is false

b)

loops through a block of code as long as a specified condition is true or false

c)

loops through a block of code as long as a specified condition is true

d)

loops through a number block of code as long as a specified condition is true

10.

what is a for loop?

a)

loops through a number of block of code one time

b)

loops through a block of code a number of times

c)

loops through a block of code one time

d)

many loops through a block of code a number of times

11.

var i = 0;

(i 10) {

console.log(i);

i++

}

fix the code using while loop and i is bigger then 10

a)

WHILE , <

b)

while , bigger

c)

while , <

d)

while , >

12.

Used to perform statements using a condition. The statements are performed first and checking whether or not to repeat the statements is done at the end of each execution.

a)

for loop

b)

while loop

c)

do while loop

13.

What type of statement that is used to skip the current iteration and move on to the next one of a for/while loop?

a)

break

b)

continue

c)

stop

d)

skip

14.

What type of statement that is used to break away from any loop body or switch statement?

a)

break

b)

continue

c)

stop

d)

skip

15.

In a for loop, this is an expression (including assignment expressions) or variable declaration evaluated once before the loop begins. Typically used to initialize a counter variable.

a)

start_point

b)

condition

c)

step

d)

variable

16.

In a for loop, this is an expression to be evaluated before each loop iteration. If this expression evaluates to true, statement is executed. If the expression evaluates to false, execution exits the loop and goes to the first statement after the for construct.

a)

start_point

b)

condition

c)

step

d)

variable

17.

When filling out your for loop, you don't have to only use numbers. You can also use letters for example.

a)

True

b)

False

18.

In a WHILE loop, the body of the loop is executed at first. Then the condition is evaluated.

a)

True

b)

False

19.

In a while/do while loop, a condition is executed at least once and is re-executed each time the statement evaluates to true.

a)

True

b)

False

20.

A statement is an expression evaluated before each pass through the loop. If this statement evaluates to true, condition is executed. When statement evaluates to false, execution continues with the condition after the while loop.

a)

True

b)

False