JS Loop while
A while loop checks its condition before each turn. Update the value that the condition depends on.
Where to run this
This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.
A practical example
let remaining = 3;
while (remaining > 0) {
console.log(remaining);
remaining -= 1;
}
What happens
The output counts down from 3 to 1.