
JavaScript Loop Mastery
Quiz
•
Computers
•
10th Grade
•
Practice Problem
•
Medium
Chris Talla
Used 7+ times
FREE Resource
Enhance your content in a minute
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the syntax for a for loop in JavaScript?
for (increment/decrement; condition; initialization) { // code to be executed }
for (initialization; condition; increment/decrement) { // code to be executed }
for (initialization; increment/decrement; condition) { // code to be executed }
for (condition; initialization; increment/decrement) { // code to be executed }
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How is a while loop different from a for loop?
A while loop continues to execute as long as the specified condition is true, whereas a for loop executes a specified number of times.
A while loop and a for loop are essentially the same and can be used interchangeably.
A while loop can only be used for numeric iterations, whereas a for loop can be used for any type of iteration.
A while loop executes a specified number of times, whereas a for loop continues to execute as long as the specified condition is true.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When would you use a do-while loop instead of a while loop?
Use a do-while loop when you want the loop to execute after checking the condition
Use a do-while loop when you want the loop to execute only if the condition is true
Use a do-while loop when you want the loop to execute at least once before checking the condition.
Use a do-while loop when you want to avoid infinite loops
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the concept of nested loops in JavaScript with an example.
Example: for (let i = 0; i < 3; i++) { for (let j = 0; j < 1; j++) { console.log('i:', i, 'j:', j); } }
Example: for (let i = 0; i < 2; i++) { for (let j = 0; j < 3; j++) { console.log('i:', i, 'j:', j); } }
Example: for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { console.log('i:', i, 'j:', j); } }
Example: for (let i = 0; i < 3; i++) { for (let j = 0; j < 2; j++) { console.log('i:', i, 'j:', j); } }
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What are the loop control statements available in JavaScript?
break, continue, return
for, while, do-while
if, else, switch
try, catch, finally
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following for loop: for(let i=0; i<5; i++){ console.log(i); }
6
0 1 2 3 4
5
7
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Write a while loop that prints numbers from 1 to 10.
let i = 1; while (i < 10) { console.log(i); i++; }
let i = 1; while (i <= 10) { console.log(i); i++; }
let i = 1; while (i <= 11) { console.log(i); i++; }
let i = 10; while (i >= 1) { console.log(i); i--; }
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
15 questions
4:3 Model Multiplication of Decimals by Whole Numbers
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
The Best Christmas Pageant Ever Chapters 1 & 2
Quiz
•
4th Grade
12 questions
Unit 4 Review Day
Quiz
•
3rd Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
