Keeping Score
Count correct.
Keeping Score 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! 🏆
Every great quiz counts how many you got right! Let's learn to keep score. 🏆
console.log('Let us count points! 🏆')Start at Zero 0️⃣
Before the quiz starts, the score is 0. Everyone begins with no points! 0️⃣
let score = 0
console.log('Score:', score)Add One Point ➕
When the answer is right, we add 1 to the score with score = score + 1. ➕
let score = 0
score = score + 1
console.log('Score:', score)A Shortcut ⚡
score++ means the same as score = score + 1, but shorter! ⚡
let score = 0
score++
score++
console.log('Score:', score)Score When Correct ✅
We only add a point when the guess is right. Let's combine score with if! ✅
let score = 0
let guess = 5
if (guess === 5) {
score++
}
console.log('Score:', score)Many Questions 📋
Let's answer three questions and watch the score grow! 📋
let score = 0
if (4 === 4) score++
if (7 === 8) score++
if (9 === 9) score++
console.log('Score:', score)Show Progress 📊
It's nice to show the score after each question so players feel excited! 📊
let score = 0
if (2 === 2) score++
console.log('After Q1, score is', score)
if (3 === 5) score++
console.log('After Q2, score is', score)Count Wrong Ones Too ❌
We can also count how many were WRONG with a second variable! ❌
let right = 0
let wrong = 0
if (6 === 6) right++; else wrong++
if (4 === 9) right++; else wrong++
console.log('Right:', right, 'Wrong:', wrong)Score in a Function 🛠️
Let's make a helper that checks an answer AND adds to the score! 🛠️
let score = 0
function grade(guess, answer) {
if (guess === answer) {
score++
console.log('Correct! 🎉')
}
}
grade(5, 5)
grade(2, 3)
console.log('Score:', score)How Many Out Of? 🔢
We can show score like 2 out of 3 by remembering the total number of questions. 🔢
let score = 2
let total = 3
console.log('You got', score, 'out of', total)Full Score Tracker 🎮
Here is a mini quiz that keeps score from start to finish! 🎮
let score = 0
let total = 3
if (1 + 1 === 2) score++
if (5 - 2 === 3) score++
if (2 * 2 === 5) score++
console.log('Final score:', score, 'out of', total)Quick Check ✅
Quick brain test! 🧠
Score Master! 🌟
You can now keep score in any quiz! 🎉
- Start the score at 0 0️⃣
- Use
score++for a point ⚡ - Show 'X out of Y' 🔢
Last step: showing the final score! 🏁
console.log('Score keeping: COMPLETE! 🌟')Frequently asked questions
Is the “Keeping Score” lesson free?
Yes — the full text of “Keeping Score” 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 “Keeping Score”?
Count correct. 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 “Keeping Score” 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
- Making Questions
- Checking Answers
- Keeping Score
- Final Score