MDN self-hosted library · e01.org
Game over / notebook

Game over

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const ballIsOutOfBounds = ball.hitbox.bottom > canvas.height;
if (ballIsOutOfBounds) {
  // Game over logic
  alert("Game over!");
  location.reload();
  return;
}