let count = 0;
while (hasMessages()) {
count++;
processMessage();
}Invariant / notebook
Invariant
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
function processInput(input) {
if (input < 0 || !Number.isInteger(input)) {
throw new Error("Input must be a non-negative integer");
}
// Process input...
}