0Pricing
Javascript for Kids · Lesson

Winning

Reach the treasure.

Winning is a free Javascript for Kids lesson on CoddyKit — lesson 3 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.

Reach the Treasure! 🏆

The hero made it! Now we build the winning ending, with treasure, cheers, and confetti! 🎊 Let us celebrate victory!

Checking for the Win 🎯

The player wins when they reach the goal. Check it with if!

let location = "treasure room"
if (location === "treasure room") {
  console.log("You found the treasure! 💰")
}

The Victory Message 🎉

Make a big, happy ending announcement!

console.log("🎉 YOU WIN! 🎉")
console.log("The golden crown is yours! 👑")

Did They Have the Key? 🗝️

Maybe winning needs an item! Check if the bag has the key.

let bag = ["torch", "key"]
if (bag.includes("key")) {
  console.log("You unlock the treasure chest! 🗝️")
} else {
  console.log("The chest is locked. You need a key!")
}

Counting the Treasure 💰

Show how much treasure the player collected!

let gold = 50
console.log("You collected " + gold + " gold coins! 🪙")

A Hero Ending 🦸

Praise the hero by name. They earned it!

let hero = "Maya"
console.log(hero + " saved the kingdom! 🏰 Everyone cheers! 📣")

Bonus for Brave Choices ⭐

Give bonus rewards if the player took the risky path!

let braveChoice = true
if (braveChoice) {
  console.log("Bonus! You earned the Brave Hero badge! 🎖️")
}

A Win Function 🛠️

Make a reusable winning helper for your adventure!

function win(hero) {
  console.log("🏆 " + hero + " wins the adventure! 🎉")
}
win("Captain Sam")

Showing the Whole Journey 🗺️

Remind the player of all the choices that led to victory!

let journey = ["went left", "found key", "opened chest"]
journey.forEach(function(step) {
  console.log("✅ " + step)
})

The Happy Ending 💖

End with a warm, happy message. The adventure is complete!

console.log("And they all lived happily ever after. 💖")
console.log("THE END 📖")

Victory Achieved! ✅

Your game now has a real winning ending with treasure, badges, and cheers! What a hero. 🦸

let won = true
if (won) {
  console.log("🎊 Congratulations, brave hero! 🎊")
}

Quick Check ❓

Win this brain teaser! 🧠

Victory Star! 🌟

Recap! You learned to:

  • 🎯 Check for the win with if
  • 🎉 Show a victory message
  • 🗝️ Check the bag with .includes()
  • 🛠️ Make a win function

Next: handling GAME OVER! 💀

Frequently asked questions

Is the “Winning” lesson free?

Yes — the full text of “Winning” 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 “Winning”?

Reach the treasure. 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 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Winning” 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