0Pricing
Javascript for Kids · Lesson

Checking the Guess

Tell the player higher or lower.

Checking the Guess 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.

Check the Guess! 🔍

Now our game needs to check the player guess! 🙋

Is it too high, too low, or just right? 🎯

The Guess Box 📦

The player picks a number. We save the secret and the guess! ✍️

let secret = 7;
let guess = 5;
console.log("Guess: " + guess);

Too Low? ⬆️

If the guess is SMALLER than the secret, say "higher!" ⬆️

let secret = 7;
let guess = 5;
if (guess < secret) {
  console.log("Try higher!");
}

Too High? ⬇️

If the guess is BIGGER than the secret, say "lower!" ⬇️

let secret = 7;
let guess = 9;
if (guess > secret) {
  console.log("Try lower!");
}

Just Right? 🎯

If the guess EQUALS the secret, they win! 🎉

let secret = 7;
let guess = 7;
if (guess === secret) {
  console.log("You got it!");
}

All Three Together! 🔀

We use if, else if, and else to check all cases! 🧩

let secret = 7;
let guess = 4;
if (guess < secret) {
  console.log("Higher!");
} else if (guess > secret) {
  console.log("Lower!");
} else {
  console.log("You win!");
}

Try a Higher Guess ⬆️

Change the guess to 9 and run. What hint do you get? 🤔

let secret = 7;
let guess = 9;
if (guess < secret) {
  console.log("Higher!");
} else if (guess > secret) {
  console.log("Lower!");
} else {
  console.log("You win!");
}

Hints Help Players 🧭

The higher/lower hints guide the player closer each time! 🎯

That makes the game fun and fair. 😊

A Checker Spell 🪄

Let us put our checker in a function! It takes a guess and gives a hint. ✨

function checkGuess(guess) {
  let secret = 7;
  if (guess < secret) return "Higher!";
  if (guess > secret) return "Lower!";
  return "You win!";
}
console.log(checkGuess(3));

Test It Out! 🧪

Try different guesses with your checker spell! 🎮

function checkGuess(guess) {
  let secret = 7;
  if (guess < secret) return "Higher!";
  if (guess > secret) return "Lower!";
  return "You win!";
}
console.log(checkGuess(10));
console.log(checkGuess(7));

The Brain Is Done! 🧠

The checker is the brain of our game! 🎉

It knows higher, lower, and win!

Quick Check 🧠

Question time! 🎯

Checker Champ! 🏆

Hooray! Your game gives higher/lower hints! 🧭

Next, we celebrate the win! 🚀

Frequently asked questions

Is the “Checking the Guess” lesson free?

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

Tell the player higher or lower. 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 the Guess” 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. Planning the Game
  2. Making the Secret Number
  3. Checking the Guess
  4. Winning the Game
← Back to Javascript for Kids