Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What is a nested loop in JavaScript?

View

How many times will the inner loop run in the following code?

View

What will be the output of this nested loop?

View

In a nested loop, how many times will the inner loop execute for each iteration of the outer loop?

View

What is the total number of times the console.log will run in the following nested loop?

View

What will be the value of i and j after the following nested loop finishes?

View

What does this code print out?

View

In a nested loop, the outer loop runs 5 times and the inner loop runs 4 times. How many times will the inner loop execute in total?

View

What happens if both loops in a nested loop are infinite loops?

View

What will be the output of the following nested loop?

View

What is a nested loop in JavaScript?

A loop inside a function
A loop inside an array
A loop inside another loop
A loop with a condition

How many times will the inner loop run in the following code?

for (let i = 0; i < 3; i++) { for (let j = 0; j < 2; j++) { console.log(i, j); } }

3
6
5
9

What will be the output of this nested loop?

for (let i = 0; i < 2; i++) { for (let j = 0; j < 2; j++) { console.log(i, j); } }

0 0, 0 1, 1 0, 1 1
1 1, 2 2
0 1, 1 2, 2 3
Infinite loop

In a nested loop, how many times will the inner loop execute for each iteration of the outer loop?

for (let i = 0; i < 4; i++) { for (let j = 0; j < 3; j++) { console.log(i, j); } }

4 times
3 times
12 times
7 times

What is the total number of times the console.log will run in the following nested loop?

for (let i = 0; i < 3; i++) { for (let j = 0; j < 4; j++) { console.log(i, j); } }

3
4
12
7

What will be the value of i and j after the following nested loop finishes?

i = 2, j = 2
i = 3, j = 2
i = 2, j = 1
i = 3, j = 0

What does this code print out?

for (let i = 1; i <= 3; i++) { for (let j = 1; j <= i; j++) { console.log(j); } }

1 1 2 1 2 3
1 2 3 1 2 3
1 2 3
1 2

In a nested loop, the outer loop runs 5 times and the inner loop runs 4 times. How many times will the inner loop execute in total?

5
4
20
9

What happens if both loops in a nested loop are infinite loops?

The inner loop runs forever while the outer loop doesn’t start
The outer loop runs forever while the inner loop runs once
Both loops run forever
Both loops terminate after one iteration

What will be the output of the following nested loop?

for (let i = 1; i < 3; i++) { for (let j = 1; j < 3; j++) { console.log(i * j); } }

1 1 2 4
1 2 2 3
1 2 2 4
1 4 2 3