{
statement1;
statement2;
// …
statementN;
}Control flow and error handling / notebook
Control flow and error handling
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
while (x < 10) {
x++;
}> var x = 1;
> {
> var x = 2;
> }
> console.log(x); // 2
>if (condition) {
statement1;
} else {
statement2;
}if (condition1) {
statement1;
} else if (condition2) {
statement2;
} else if (conditionN) {
statementN;
} else {
statementLast;
}if (condition) {
// Statements for when condition is true
// …
} else {
// Statements for when condition is false
// …
}