The Iteration Echo

EasyAcc. 97.5%
+15 XP 5

Precise Cycles

While a do-while loop is known for running at least once, it can also be used as a standard counter. By incrementing a variable inside the block, you can repeat an action for a specific number of times.

The Assignment

Your function receives a parameter named limit.

  1. Declare a variable count and initialize it to 0.
  2. Write a do-while loop that continues as long as count is less than limit.
  3. Inside the loop:
    • Print the message: "Iteration " + (count + 1)
    • Advance the value of count by 1.

01EXAMPLE 1

Inputlimit = 4
OutputIteration 1 Iteration 2 Iteration 3 Iteration 4

Explanation: Loop runs 4 times.

02EXAMPLE 2

Inputlimit = 2
OutputIteration 1 Iteration 2

Explanation: Loop runs 2 times.

Constraints

  • Use a do-while loop.
  • Log messages must exactly match the "Iteration X" format.
LoopsFundamentals
JavaScript
Loading...
3 Hidden

Input Arguments

limit4

Expected Output

Iteration 1
Iteration 2
Iteration 3
Iteration 4

Click RUN to test your solution