MDN self-hosted library · e01.org

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.

js
if (condition) {
  /* code to run if condition is true */
} else {
  /* run some other code instead */
}
js
if (condition) {
  /* code to run if condition is true */
}

/* run some other code */