
Mastering JavaScript Control Structures
Quiz
•
Computers
•
10th Grade
•
Practice Problem
•
Medium
Tarik Sulić
Used 1+ times
FREE Resource
Enhance your content in a minute
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the basic syntax of a for loop in JavaScript?
for (initialization; increment) // code to be executed
for (increment; condition) { // code }
for (condition; initialization; increment) { // code }
for (initialization; condition; increment) { // code to be executed }
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you declare a variable in a for loop?
You declare a variable in a for loop with 'assign'.
You declare a variable in a for loop using 'declare'.
You declare a variable in a for loop using 'let', 'const', or 'var'.
You declare a variable in a for loop using 'define'.
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the purpose of the initialization statement in a for loop?
To determine the number of iterations in the loop.
To execute the loop body only once.
To increment the loop control variable after each iteration.
To set the initial value of the loop control variable.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the difference between a for loop and a while loop?
A for loop iterates a known number of times, while a while loop continues until a condition is false.
A for loop is used for conditional statements, while a while loop is used for iteration.
A for loop runs indefinitely, while a while loop stops after a set number of iterations.
A for loop can only be used with arrays, while a while loop can be used with any data type.
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Provide an example of a while loop that counts from 1 to 5.
i = 1 while i <= 5: print(i) i += 1
i = 1 while i < 5: print(i) i += 1
i = 0 while i <= 5: print(i) i += 1
i = 1 while i < 6: print(i) i += 2
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will happen if the condition in a while loop is always true?
The loop will run a fixed number of times.
The program will skip the loop entirely.
The program will enter an infinite loop.
The program will terminate immediately.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you write an if statement to check if a number is positive?
if (number > 0) { /* code to execute if number is positive */ }
if (number < 0) { /* code to execute if number is negative */ }
if (number == 0) { /* code to execute if number is zero */ }
if (number >= 0) { /* code to execute if number is non-negative */ }
Access all questions and much more by creating a free account
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
15 questions
Data Security Worksheet
Quiz
•
10th Grade - University
16 questions
Se liga - 1 - 6° anos
Quiz
•
6th Grade - University
20 questions
BT VỀ HĐH
Quiz
•
10th Grade
21 questions
Google : ¡A trabajar!
Quiz
•
10th - 11th Grade
20 questions
2324tx6
Quiz
•
9th - 12th Grade
15 questions
# REVIEW 1 DATA TYPES
Quiz
•
10th Grade
20 questions
Network topologies
Quiz
•
8th Grade - University
15 questions
Quiz 1
Quiz
•
1st - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
