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.
- Declare a variable
countand initialize it to 0. - Write a
do-whileloop that continues as long ascountis less thanlimit. - Inside the loop:
- Print the message: "Iteration " + (count + 1)
- Advance the value of
countby 1.
01EXAMPLE 1
Input
limit = 4Output
Iteration 1
Iteration 2
Iteration 3
Iteration 4Explanation: Loop runs 4 times.
02EXAMPLE 2
Input
limit = 2Output
Iteration 1
Iteration 2Explanation: Loop runs 2 times.
Constraints
- Use a do-while loop.
- Log messages must exactly match the "Iteration X" format.
LoopsFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
limit4
Expected Output
Iteration 1 Iteration 2 Iteration 3 Iteration 4
Click RUN to test your solution