0 of 8 problems solved • 0%

Exercise prompt

Trace a Loop Counter

A variable declared before a loop remains available after the loop. Its lifetime is not limited to the loop block.

Example

let count = 0; while (count < 2) { count += 1; } console.log(count); // outputs 2

Predict the output

A loop counter is declared before the loop begins. Predict all messages, including the final counter value.

let step = 0; for (; step < 3; step += 1) { console.log("Step:", step); } console.log("Finished:", step);
What will this code print?