Checking Guesses
Compare answers.
Checking Guesses 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.
Did They Guess Right? 🤔
The player typed a guess. Now the computer must compare it to the secret animal. Let us learn how! 🔍
Comparing Two Words ⚖️
We use === (three equals) to ask "are these the same?". It gives back true or false.
console.log("cat" === "cat")
console.log("cat" === "dog")True and False 🚦
These special words are called booleans. true means YES, false means NO. Like a green or red light!
let isMatch = "lion" === "lion"
console.log("Is it a match?", isMatch)The Magic if Statement ✨
An if runs code ONLY when something is true. Super powerful!
let guess = "frog"
if (guess === "frog") {
console.log("That is correct! 🎉")
}Else: The Other Path 🛤️
What if they are wrong? else handles that case. Now we cover BOTH paths!
let guess = "cat"
if (guess === "dog") {
console.log("Correct!")
} else {
console.log("Nope, try again! 🙃")
}Checking Against the Secret 🔐
Compare the player guess with our secret animal name.
let secret = "lion"
let guess = "lion"
if (guess === secret) {
console.log("You found the " + secret + "! 🦁")
} else {
console.log("Not quite!")
}Big or Small Letters? 🔠
"Lion" and "lion" are NOT the same to the computer. We make everything lowercase to be fair!
let guess = "LION"
let secret = "lion"
console.log(guess.toLowerCase() === secret)A Checking Function 🛠️
Let us build a helper that checks any guess. Reuse it as many times as we want!
function check(guess, secret) {
return guess.toLowerCase() === secret.toLowerCase()
}
console.log(check("Dog", "dog"))Giving Helpful Feedback 💬
Tell the player if they got it or not. Kind games keep players happy! 😊
function check(guess, secret) {
if (guess === secret) {
console.log("Yes! Correct! ✅")
} else {
console.log("Not this time. ❌")
}
}
check("cat", "cat")More Tries Please! 🔁
Games are fun when you get more than one try. We can count guesses!
let tries = 0
tries = tries + 1
console.log("This is guess number " + tries)Guess Checker Done! ✅
You can now compare a guess to the secret and respond. The brain of the game works! 🧠
let secret = "owl"
let guess = "owl"
let correct = guess === secret
console.log(correct ? "Winner! 🏆" : "Keep guessing!")Quick Check ❓
Brain power time! 💪
Guess Detective! 🕵️
Recap! You learned:
- ⚖️ Compare with
=== - 🚦 true and false booleans
- ✨
ifandelse - 🔠
.toLowerCase()to be fair
Next: celebrating a WIN! 🎉
Frequently asked questions
Is the “Checking Guesses” lesson free?
Yes — the full text of “Checking Guesses” 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 “Checking Guesses”?
Compare 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 “Checking Guesses” 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
- A List of Animals
- Giving Clues
- Checking Guesses
- You Got It!