0Pricing
Javascript for Kids · Lesson

More Choices with else if

Pick between several options.

More Choices! 🎚️

Hi, choice master! 🌟 Sometimes we have MORE than two choices.

We use else if to add more doors to check! 🚪🚪🚪

let n = 2
if (n === 1) {
  console.log("One")
} else if (n === 2) {
  console.log("Two! ✌️")
} else {
  console.log("Something else")
}

A Chain of Choices ⛓️

else if goes between if and else.

The computer checks each door from top to bottom until one is true! 🪜

let color = "red"
if (color === "blue") {
  console.log("Sky! 🔵")
} else if (color === "red") {
  console.log("Apple! 🍎")
}

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