if (condition) {
/* code to run if condition is true */
} else {
/* run some other code instead */
}Making decisions in your code — conditionals / notebook
Making decisions in your code — conditionals
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
if (condition) {
/* code to run if condition is true */
}
/* run some other code */