Tracking Dice Points
Track points.
Tracking Dice 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.
Keeping Score! 🏅
Games are more fun when we keep points! 🏅
Let's learn how to add up your dice rolls and remember your score! 🧠
console.log('Time to keep score! 🏅')
console.log('Add up your points! ➕')A Score Box 📦
First we make a box to hold the score and start it at 0. 📦
We use let so we can change it later!
let score = 0
console.log('Starting score: ' + score + ' 🏅')Add a Roll to the Score ➕
When you roll, add the number to your score! ➕
If you roll a 4, your score goes up by 4. 🎲
let score = 0
let roll = 4
score = score + roll
console.log('Rolled ' + roll + '. Score: ' + score + ' 🏅')Shortcut: += ⚡
Typing score = score + roll a lot is tiring! 😅
There's a shortcut: score += roll. It means the same thing! ⚡
let score = 0
score += 3
score += 5
console.log('Score: ' + score + ' ⚡')Add Many Rolls 🎲🎲🎲
Let's roll three times and add each to the score! 🎲🎲🎲
Watch the score grow! 📈
let score = 0
score += Math.floor(Math.random() * 6) + 1
score += Math.floor(Math.random() * 6) + 1
score += Math.floor(Math.random() * 6) + 1
console.log('Total score: ' + score + ' 🏅')Score in a Loop 🔁
A loop makes it tidy! Let's roll 5 times in a loop and add to score. 🔁
The score box remembers everything! 🧠
let score = 0
for (let i = 1; i <= 5; i++) {
let roll = Math.floor(Math.random() * 6) + 1
score += roll
console.log('Roll ' + i + ': ' + roll + ' (score ' + score + ')')
}Two Player Scores 👥
Two players? Make two score boxes! 👥
One for player 1 and one for player 2. 📦📦
let player1 = 0
let player2 = 0
player1 += 6
player2 += 4
console.log('Player 1: ' + player1 + ' 🏅')
console.log('Player 2: ' + player2 + ' 🏅')Who Has More? ⚖️
We can compare scores to see who's winning! ⚖️
Use > which means "greater than". 🔼
let player1 = 8
let player2 = 5
if (player1 > player2) {
console.log('Player 1 is winning! 🏆')
} else {
console.log('Player 2 is winning! 🏆')
}Bonus Points! 🎁
Let's give a bonus! If you roll a 6, add an extra 2 points! 🎁
Lucky rolls deserve rewards! 🍀
let score = 0
let roll = 6
score += roll
if (roll === 6) {
score += 2
console.log('Bonus! +2 🎁')
}
console.log('Score: ' + score + ' 🏅')Show the Scoreboard 📊
Let's print a nice scoreboard at the end! 📊
Players love to see who won! 🏆
let p1 = 12
let p2 = 9
console.log('=== SCOREBOARD === 📊')
console.log('Player 1: ' + p1)
console.log('Player 2: ' + p2)You're a Score Keeper! 🏅
Fantastic! You can track points now! 🎉
- A score box starts at 0 📦
+=adds points ⚡- Compare with
>to find the winner ⚖️
console.log('You keep score now! ✅')
console.log('Next: First to Twenty! 🎯')Quick Check 🧠
Brain question! 🤔
Awesome! 🎉
You can keep score in your dice game! 🏅
- Score box starts at 0 📦
- Add points with
+=⚡ - Compare to find the winner ⚖️
Next: let's build First to Twenty! 🎯
console.log('Lesson done! ⭐')
console.log('Build the game next! 🎯')Frequently asked questions
Is the “Tracking Dice Points” lesson free?
Yes — the full text of “Tracking Dice 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 “Tracking Dice Points”?
Track points. 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 “Tracking Dice 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
- Rolling a Die
- Two Dice
- Tracking Dice Points
- First to Twenty