
Mastering JavaScript Control Structures

Quiz
•
Computers
•
10th Grade
•
Medium
Tarik Sulić
Used 1+ times
FREE Resource
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 */ }
Create a free account and access millions of resources
Similar Resources on Wayground
19 questions
Computer Science Quiz 02

Quiz
•
10th Grade - University
15 questions
Iteration

Quiz
•
9th - 12th Grade
20 questions
Game Lab Basics

Quiz
•
9th - 12th Grade
20 questions
iGCSE Computer Science: Programming Languages

Quiz
•
9th - 12th Grade
20 questions
Python - lists,loops,basics

Quiz
•
9th - 11th Grade
20 questions
Python Loops Quiz

Quiz
•
10th Grade
15 questions
coding

Quiz
•
KG - Professional Dev...
24 questions
Java Loops

Quiz
•
10th - 12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
1.2 OSI & TCP IP Models Quiz

Quiz
•
10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade