Language concepts

Loop termination

Try the free JavaScript compiler

A termination argument identifies progress toward a false condition or a deliberate control transfer. An invariant alone does not prove termination; show a bounded measure decreases or otherwise establish finite progress.

Formal Syntax & Structure

javascript syntaxjavascript
while (remaining > 0) { remaining--; }

Working Example

Example Snippetjavascript
let remaining=3; while(remaining>0){remaining--;} console.log(remaining);
JavaScript Reference