Language concepts
Loop invariant
A property chosen to hold before the first iteration and be preserved by every completed iteration at the chosen point. Together with exit conditions it helps prove correctness.
Formal Syntax & Structure
javascript syntaxjavascript
// At loop head: processed + remaining === initialWorking Example
Example Snippetjavascript
let a=3,b=0; while(a>0){a--;b++;} console.log(a+b);