Published lesson · 25 minutes

Make decisions with conditionals

Objective: Use conditions to choose a response for different inputs and boundary cases.

Understand the idea

This lesson focuses on make decisions with conditionals. Use conditions to choose a response for different inputs and boundary cases. We will use a familiar community situation to make the idea concrete, then break it into decisions you can explain. You do not need special equipment or previous experience beyond the course prerequisites.

A resource page could display a message when a search finds no matching service, instead of leaving an empty area. Start by naming the information or action involved, then consider what a visitor or learner needs to understand. This small planning step makes the example easier to follow and helps you notice assumptions before they become confusing.

An if statement runs a branch when its condition is true; else handles a different case. The example is synthetic and contains no real organisation, personal details or promises about services. Treat it as a learning model: adapt the structure to your own situation, and check details with the people responsible before publishing anything publicly.

Write conditions in plain language first, including what happens at zero or when a value is missing. Test both branches with small examples. Try changing one detail at a time and describe what changed. When something behaves differently from what you expected, return to the goal and inspect the relevant part instead of changing several things at once.

Clear branching makes a program easier to trust and easier to explain to another person. A useful review asks whether the result is clear, usable and appropriate for the intended audience. Invite another person to try it when possible, and make improvements based on what they can actually understand or do.

Worked examples

Make decisions with conditionals: a small example

See how make decisions with conditionals can help communicate or solve a practical community task.

main.js

const places = 0
if (places > 0) {
  console.log("Places are available")
} else {
  console.log("Join the waiting list")
}

Practice tasks

  1. Explore make decisions with conditionals

    Use the worked example for “Make decisions with conditionals”. Change one small detail to suit a different synthetic community situation, then explain what you expected and how you checked whether the change still met the lesson objective.

  2. Build a JavaScript practice example

    Create a small practice result that demonstrates this objective: Use conditions to choose a response for different inputs and boundary cases. Use only synthetic information, keep the first version focused, and write down one limitation that a later version should address.

  3. Review and explain the result

    Review your “Make decisions with conditionals” result as if another learner will use it without your explanation. Identify one strength, one exact point that may be unclear, and a revision that would make the result easier to understand or use.

Make decisions with conditionals becomes easier when you start with a clear purpose, try one small step and check the result from the learner or community member's point of view.

Course overview