Search Header Logo

Week 4.2

Authored by Poul Nichols

Computers

Professional Development

Used 2+ times

Week 4.2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax of a for loop in JavaScript?

for (initialization; condition; increment/decrement) { // Block of Code }

for { // Block of Code } (initialization; condition; increment/decrement)

for [initialization; condition; increment/decrement] { // Block of Code }

for (condition; initialization; increment/decrement) { // Block of Code }

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a for loop?

To execute a block of code repeatedly while a condition is true

To execute a block of code repeatedly until a condition is true

To execute a block of code once

To execute a block of code randomly

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between i++ and ++i in a for loop?

There is no difference

i++ increments i after the expression is evaluated, while ++i increments i before the expression is evaluated

i++ increments i by 2, while ++i increments i by 1

i++ decrements i, while ++i increments i

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

for (let i = 0; i < 5; i++) { console.log(i); }

0 1 2 3 4

1 2 3 4 5

0 1 2 3 4 5

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements is true about a nested for loop in JavaScript?

It is a loop inside another loop.

It can only iterate over arrays.

It can only iterate over objects.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

for (var i = 1; i <= 10; i++) {

if (i == 3) { document.write("*");}

}

*

*****

**********

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code?

for (var i = 3; i >= 1; i--) {

for (var j = 1; j <= i; j++) {document.write("*"); }

document.write("<br>"); }

*

***

***

***

*

**

***

***

**

*

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?