Scoring
Count correct answers.
Scoring 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.
Keep the Score! 🏆
A quiz show needs a SCORE! We count how many questions the player gets right. Let us build the scoreboard! 📊
Start at Zero 0️⃣
Every game starts with a score of 0. We make a variable to hold it.
let score = 0
console.log("Starting score:", score)Adding a Point ➕
When the player is right, add 1 point! Use score = score + 1.
let score = 0
score = score + 1
console.log("Score is now:", score)The Shortcut: += ⚡
score += 1 means the same thing but shorter! Coders love shortcuts.
let score = 0
score += 1
score += 1
console.log("Score:", score)Check Then Score ✅
Only add a point if the answer is correct. Combine if with scoring!
let score = 0
let answer = "blue"
let guess = "blue"
if (guess === answer) {
score += 1
}
console.log("Score:", score)Wrong Answer? No Point 🚫
If they are wrong, the score stays the same. Use else for a kind message.
let score = 0
let guess = "red"
let answer = "green"
if (guess === answer) {
score += 1
} else {
console.log("Oops, no point this time! 🙃")
}
console.log("Score:", score)Scoring in a Loop 🔁
Loop through answers and add up the points. The scoreboard grows!
let answers = ["blue", "green", "white"]
let guesses = ["blue", "red", "white"]
let score = 0
for (let i = 0; i < answers.length; i++) {
if (guesses[i] === answers[i]) score += 1
}
console.log("Final score:", score)A Scoring Function 🛠️
Build a helper that checks an answer and returns a point. Reuse it for every question!
function points(guess, answer) {
return guess === answer ? 1 : 0
}
console.log(points("cat", "cat"))
console.log(points("cat", "dog"))Show the Score Live 📺
Tell the player their score after each question. Keeps the excitement up!
let score = 2
console.log("Your score so far: " + score + " points! 🌟")Bonus Points! ⭐
Make it fun! Give extra points for hard questions.
let score = 5
score += 3
console.log("Bonus! New score: " + score + " 🎉")The Scoreboard Works! ✅
You can now track points, add them up in a loop, and show the score. Real quiz show stuff! 🎬
let score = 0
["a", "b", "c"].forEach(function() { score += 1 })
console.log("Total points:", score)Quick Check ❓
Score yourself with this one! 🧠
Scorekeeper Star! 🌟
Recap! You learned to:
- 0️⃣ Start the score at zero
- ➕ Add points with
+= - ✅ Score only correct answers with
if - 🔁 Total points in a loop
Next: showing the final score! 🏁
Frequently asked questions
Is the “Scoring” lesson free?
Yes — the full text of “Scoring” 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 “Scoring”?
Count correct answers. 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 “Scoring” 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.