NEW
Font size
WorksheetsQuiz No. 3 - JS Loops
Total questions: 20
Worksheet time: 14mins
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++; }
hi hi hi hi
hi hi hi
hi hi
hi
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");
hi bye
hi
bye
hi
bye
hi
bye
hi
hi
hi
bye
hi
hi
bye
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"); }
hi
it won't output anything
it will output an error
hi hi
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);
3
6
7
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 i = 3; while (i < 6) { println(i); i += 1; }
1
2
3
4
5
6
3
4
5
3
4
5
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++; }
1
2
3
0
1
2
3
1
2
3
4
0
1
2
Consider the following code:
let i; (i = 0; i<10; i++ ) { console.log(i); }
It creates a loop that runs from 0 to 9
It creates a loop that runs from 1 to 9
It creates a loop that runs from 9 to 0
It creates a loop that runs from 9 to 1
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?
for (i = 0; i < 5 i++)
FOR (i = 0; i < 5; i++)
for (i = 0; i < 4; i++)
for (i = 0; i < 5; i++)
what is a while loop?
loops through a block of code as long as a specified condition is false
loops through a block of code as long as a specified condition is true or false
loops through a block of code as long as a specified condition is true
loops through a number block of code as long as a specified condition is true
what is a for loop?
loops through a number of block of code one time
loops through a block of code a number of times
loops through a block of code one time
many loops through a block of code a number of times
var i = 0;
(i 10) {
console.log(i);
i++
}
fix the code using while loop and i is bigger then 10
WHILE , <
while , bigger
while , <
while , >
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.
for loop
while loop
do while loop
What type of statement that is used to skip the current iteration and move on to the next one of a for/while loop?
break
continue
stop
skip
What type of statement that is used to break away from any loop body or switch statement?
break
continue
stop
skip
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.
start_point
condition
step
variable
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.
start_point
condition
step
variable
When filling out your for loop, you don't have to only use numbers. You can also use letters for example.
True
False
In a WHILE loop, the body of the loop is executed at first. Then the condition is evaluated.
True
False
In a while/do while loop, a condition is executed at least once and is re-executed each time the statement evaluates to true.
True
False
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.
True
False
