Mastering JavaScript Control Structures

Mastering JavaScript Control Structures

10th Grade

20 Qs

quiz-placeholder

Similar activities

Karel the Dog Review

Karel the Dog Review

9th - 12th Grade

20 Qs

Flow charts and pseudo code

Flow charts and pseudo code

9th - 11th Grade

16 Qs

Computer science paper 2

Computer science paper 2

10th Grade

15 Qs

Python Basics - yr 9

Python Basics - yr 9

9th - 12th Grade

18 Qs

Python year 9

Python year 9

8th - 11th Grade

20 Qs

Arduino Loop

Arduino Loop

2nd Grade - University

20 Qs

[AP CSP] FOR & WHILE LOOPS

[AP CSP] FOR & WHILE LOOPS

9th Grade - University

20 Qs

Javascript Basics Test

Javascript Basics Test

7th - 12th Grade

20 Qs

Mastering JavaScript Control Structures

Mastering JavaScript Control Structures

Assessment

Quiz

Computers

10th Grade

Medium

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?