0Pricing
Javascript for Kids · Lesson

Plan B with else

Do something different when it is false.

Plan B with else is a free Javascript for Kids lesson on CoddyKit — lesson 2 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.

Plan B with else 🅱️

Hi, clever coder! 🌟 What if the rule is NOT true? We need a Plan B!

We use the magic word else for "otherwise, do THIS". 🪄

if (false) {
  console.log("Plan A")
} else {
  console.log("Plan B! 🅱️")
}

If This, Else That 🔀

else always comes right after an if.

If the rule is true, do the first part. Otherwise, do the else part! 🚪🚪

if (true) {
  console.log("Door A 🚪")
} else {
  console.log("Door B 🚪")
}

Sunny or Rainy? 🌦️

Let us decide what to wear!

If it is sunny, wear sunglasses. Else, grab an umbrella! ☂️

let sunny = true
if (sunny) {
  console.log("Wear sunglasses! 😎")
} else {
  console.log("Grab an umbrella! ☂️")
}

Try the Other Way 🔄

Now change sunny to false and see Plan B happen!

One of them ALWAYS runs. 🎯

let sunny = false
if (sunny) {
  console.log("Wear sunglasses! 😎")
} else {
  console.log("Grab an umbrella! ☂️")
}

Big or Small? 📏

Let us check a number!

If it is big, cheer. Else, say it is small. 🎈

let number = 3
if (number > 10) {
  console.log("Big number! 🎉")
} else {
  console.log("Small number 🐜")
}

Pass or Try Again 🎯

In a game, you either pass or try again!

If score is high, you pass. Else, try again. 💪

let score = 40
if (score > 50) {
  console.log("You passed! 🌟")
} else {
  console.log("Try again! 💪")
}

Secret Word Check 🗝️

If the secret word is right, open the chest. Else, keep it locked!

Else makes it safe. 🔒

let word = "wrong"
if (word === "open") {
  console.log("Unlocked! 💎")
} else {
  console.log("Still locked! 🔒")
}

Only One Runs 1️⃣

Remember: only ONE part runs. Either the if OR the else, never both!

It is one or the other. 🤝

if (5 > 100) {
  console.log("This is skipped")
} else {
  console.log("This one runs! ✅")
}

Hungry or Full? 🍕

Let us decide about snacks!

If hungry, eat. Else, go play! 🎮

let hungry = true
if (hungry) {
  console.log("Time for a snack! 🍕")
} else {
  console.log("Time to play! 🎮")
}

Day or Night? 🌞🌜

If it is day, play outside. Else, go to sleep!

Change isDay and see what happens. 😴

let isDay = true
if (isDay) {
  console.log("Play outside! 🌞")
} else {
  console.log("Time to sleep! 🌜")
}

Your Turn for Plan B 🧒

Change the number and watch which plan runs!

You are in control. 🎮

let stars = 2
if (stars > 5) {
  console.log("Superstar! 🌟")
} else {
  console.log("Keep collecting! ⭐")
}

Quick Check ✅

Quick question! You are doing great! 🌟

Plan B Pro! 🏆

Excellent! 🎉 Today you learned:

  • else is your Plan B
  • It runs when the if rule is false
  • Only ONE part runs, never both

You are an else expert! ⭐

if (false) {
  console.log("A")
} else {
  console.log("I learned else! 🎉")
}

Frequently asked questions

Is the “Plan B with else” lesson free?

Yes — the full text of “Plan B with else” 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 “Plan B with else”?

Do something different when it is false. 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 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Plan B with else” 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