0Pricing
Javascript for Kids · Lesson

Game Over

Handle losing.

Game Over is a free Javascript for Kids lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Javascript for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Game Over! 💀

Not every choice leads to treasure! Sometimes the hero loses. We need a Game Over ending too, so the game feels real. Let us build it! 😬

When the Hero Loses 🐉

Falling in a trap or meeting a dragon can end the game. Check it with if!

let event = "dragon"
if (event === "dragon") {
  console.log("The dragon caught you! 🐉")
}

The Game Over Message 💀

Make a clear ending message so the player knows the round is done.

console.log("💀 GAME OVER 💀")
console.log("Better luck next time! 🍀")

Losing All Your Lives 💔

When lives reach 0, it is game over! Check it.

let lives = 0
if (lives <= 0) {
  console.log("No lives left! Game over. 💔")
}

Wrong Path, Bad End 🚫

A bad choice can end the adventure. Use else for the unlucky path!

let choice = "touch lava"
if (choice === "step back") {
  console.log("Safe! 😅")
} else {
  console.log("Ouch! The lava got you! 🌋 Game over.")
}

Be Kind to the Player 🤗

Even in defeat, be encouraging! Kind games keep players happy.

console.log("You did your best, hero! 💪")
console.log("Try a different path next time! 🌟")

Show What Went Wrong 🔍

Tell the player WHY they lost so they can learn for next time.

let reason = "you opened the wrong door"
console.log("Game over because " + reason + ". 🚪")

A Game Over Function 🛠️

Make a reusable game-over helper. Use it for any bad ending!

function gameOver(reason) {
  console.log("💀 GAME OVER: " + reason)
}
gameOver("the bridge collapsed")

Try Again? 🔁

Great games let you retry! Offer another chance.

let tryAgain = true
if (tryAgain) {
  console.log("Want to try again? Type yes! 🔄")
}

Counting Attempts 🔢

Track how many times the player has tried. Practice makes perfect!

let attempts = 2
attempts += 1
console.log("Attempt number " + attempts + " 💪")

Your Adventure is Complete! ✅

Your game now handles BOTH winning and losing. A full adventure with happy and sad endings! You are a game designer! 🎮

let alive = false
if (alive) {
  console.log("Keep going! 🦸")
} else {
  console.log("Game over. Try again! 🔄")
}

Quick Check ❓

The final brain teaser of the whole course! 🧠

Adventure Master! 🏆

You finished the Adventure Story Game! Recap:

  • 💀 Show a Game Over message
  • 💔 End when lives reach 0
  • 🤗 Be kind and encouraging
  • 🔁 Offer a retry

You built a complete adventure with branching, winning, AND losing. You are a true game maker! 🌟🎮

Frequently asked questions

Is the “Game Over” lesson free?

Yes — the full text of “Game Over” is free to read here on the web, and the Javascript for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Javascript for Kids course, upgrade to CoddyKit PRO.

What will I learn in “Game Over”?

Handle losing. You practise Javascript for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Javascript for Kids?

No prior experience is required. Javascript for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Game Over” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Javascript for Kids lesson?

Yes. Every Javascript for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Planning the Adventure
  2. Making Choices
  3. Winning
  4. Game Over
← Back to Javascript for Kids