Mastering JavaScript Control Structures

Mastering JavaScript Control Structures

10th Grade

20 Qs

quiz-placeholder

Similar activities

Advantages and Disadvantages of Collecting Data

Advantages and Disadvantages of Collecting Data

10th Grade

20 Qs

¿Qué es un sistema operativo?

¿Qué es un sistema operativo?

10th Grade

19 Qs

AI Checkpoint 1 Revision

AI Checkpoint 1 Revision

9th - 12th Grade

16 Qs

Pretest TIK

Pretest TIK

10th Grade

20 Qs

Cyber Security KS4

Cyber Security KS4

8th - 12th Grade

15 Qs

TIN 9 BÀI 1,2

TIN 9 BÀI 1,2

1st - 12th Grade

15 Qs

Informática I (17-18-A)

Informática I (17-18-A)

10th Grade

20 Qs

la internet

la internet

3rd - 11th Grade

20 Qs

Mastering JavaScript Control Structures

Mastering JavaScript Control Structures

Assessment

Quiz

Computers

10th Grade

Practice Problem

Medium

Created by

Tarik Sulić

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?