Repeat while a condition stays true.

While Loops

while_loop.js
const start = 3;
let value = start;
let steps = 0;
while (value > 0) {
  value -= 1;
  steps += 1;
}

console.log("start=" + start);
console.log("steps=" + steps);
while-loop A `while` loop checks its condition before every iteration. The loop body must move the state toward stopping.