0Pricing
Javascript for Kids · Lesson

Making a Choice with if

Do something only when a condition is true.

Making a Choice with if is a free Javascript for Kids lesson on CoddyKit — lesson 1 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.

Making Choices 🤔

Hi, decision hero! 🌟 Computers can make choices, just like you!

We use a magic word if to say "IF this is true, do something". 🪄

if (true) {
  console.log("Yes! 🎉")
}

What is True? ✅

Some things are true and some are false.

"The sky is up" is true ☀️. "Fish can fly" is false 🐟. Computers love true and false!

console.log(true)
console.log(false)

The if Statement 🚪

An if is like a door. If the rule inside ( ) is true, the door opens and the code inside { } runs!

If it is false, the door stays shut. 🔒

if (true) {
  console.log("The door opened! 🚪")
}

Comparing Numbers 🔢

We can check if a number is bigger using >.

5 > 3 is true because 5 IS bigger than 3! 🎈

if (5 > 3) {
  console.log("5 is bigger! 🎉")
}

A Locked Door 🔒

If the rule is false, the code inside does NOT run.

Watch: nothing happens because 2 > 9 is false. 😴

if (2 > 9) {
  console.log("You will NOT see this")
}
console.log("But you see this! 👋")

Using a Box 📦

We can check the value inside a box!

Here we check if age is big enough for the big slide. 🛝

let age = 10
if (age > 7) {
  console.log("You can ride the big slide! 🛝")
}

Are They Equal? 🟰

We use === (three equals) to check if two things are the SAME.

"cat" === "cat" is true! 🐱

if ("cat" === "cat") {
  console.log("Same animal! 🐱")
}

Magic Password 🗝️

Let us make a secret password check!

If the password matches, the treasure chest opens! 💎

let password = "open"
if (password === "open") {
  console.log("Chest unlocked! 💎")
}

Checking Your Score 🎮

In games, we check scores with if!

If your score is high enough, you win a star! ⭐

let score = 100
if (score > 50) {
  console.log("You win a star! ⭐")
}

Two Things at Once 🎯

You can put many lines inside the { }! They ALL run if the rule is true.

Like getting two prizes at once! 🎁🎁

if (true) {
  console.log("Prize one! 🎁")
  console.log("Prize two! 🎁")
}

Your Turn to Decide 🧒

Change the number and see if the door opens!

Try making it bigger or smaller than 5. 🚪

let candy = 8
if (candy > 5) {
  console.log("Lots of candy! 🍬")
}

Quick Check ✅

Decision time! You can solve this! 🧠

Decision Hero! 🏆

Wonderful! 🎉 Today you learned:

  • if makes a choice
  • The code runs only if the rule is true
  • Use > and === to compare

You are a decision-making champion! ⭐

if (true) {
  console.log("I can use if! 🎉")
}

Frequently asked questions

Is the “Making a Choice with if” lesson free?

Yes — the full text of “Making a Choice with if” 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 “Making a Choice with if”?

Do something only when a condition is true. 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 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Making a Choice with if” 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. Making a Choice with if
  2. Plan B with else
  3. Comparing Things
  4. More Choices with else if
← Back to Javascript for Kids