0Pricing
Javascript for Kids · Lesson

Losing Points

Decrease it.

Losing Points 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.

Uh Oh, Losing Points! ➖

Sometimes in games, you LOSE points! Make a mistake? The score goes down. Let us learn how to subtract. 😬

Take Away One Point 1️⃣

To lose a point, subtract 1: score = score - 1.

let score = 5
score = score - 1
console.log("Score:", score)

The -= Shortcut ⚡

score -= 1 is the short way to subtract. Just like += but for losing!

let score = 5
score -= 1
console.log("Score:", score)

Lose More Points 💥

Big mistakes cost more! Subtract 3 or 5 at once.

let score = 10
score -= 3
console.log("Ouch! Score:", score)

Do Not Go Below Zero! 🛑

Scores should not go negative. Use if to keep it at 0 or above!

let score = 1
score -= 5
if (score < 0) {
  score = 0
}
console.log("Score:", score)

Lose a Point When Wrong ❌

Subtract a point only when the player makes a mistake.

let score = 5
let madeMistake = true
if (madeMistake) {
  score -= 1
}
console.log("Score:", score)

Losing in a Loop 🌀

Lots of mistakes? A loop can subtract for each one.

let score = 10
for (let i = 0; i < 3; i++) {
  score -= 1
}
console.log("Score:", score)

A Lose Points Function 🛠️

Make a helper that takes points away, but never below zero!

function lose(score, amount) {
  let result = score - amount
  return result < 0 ? 0 : result
}
console.log(lose(2, 5))

Warn the Player ⚠️

Tell the player they lost points so they can be careful!

let score = 8
score -= 2
console.log("Oh no, you lost 2 points! 😱 Score:", score)

Losing a Life 💔

Some games take a LIFE instead of points. Same idea with -=!

let lives = 3
lives -= 1
console.log("Lives left:", lives, "💔")

Subtracting Works! ✅

You can now lose points safely, keep the score above zero, and warn the player. Balanced game! ⚖️

let score = 5
score -= 2
if (score < 0) score = 0
console.log("Final score: " + score)

Quick Check ❓

Do not lose points on this one! 🧠

Subtraction Star! 🌟

Recap! You learned to:

  • ➖ Subtract points with -=
  • 🛑 Stop the score from going below 0
  • ❌ Lose points only on mistakes
  • 🛠️ Use a safe lose function

Next: showing the score! 📺

Frequently asked questions

Is the “Losing Points” lesson free?

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

Decrease it. 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 “Losing Points” 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. Starting at Zero
  2. Adding Points
  3. Losing Points
  4. Showing the Score
← Back to Javascript for Kids