This is one foundational lesson in the twelve-lesson course.
The question to explore
Do I need an umbrella?
How does one piece of information change the next step?
Try rain, no rain and an unknown forecast. A workflow uses the information it has to choose the next action. Missing information needs its own path. Useful automation chooses its next action from a result. Switch between rain, no rain and an unknown forecast. The three branches show how to continue when information is available and pause when it is missing.
Local teaching illustration / No AI model call / About 9 minutes / No account needed
Try the experiment
First step: Start with Unknown. Read why the decision waits.
1. Look for the forecast 2. Pause the umbrella decision 3. Check the missing forecast The forecast is unknown. Check before deciding whether to take an umbrella.
Change a control to explore the example when JavaScript is enabled.
- Start with Unknown. Read why the decision waits.
- Choose Rain expected in Forecast. Follow the steps to Take an umbrella.
- Choose No rain expected, then Unknown. Explain why missing information should not quietly become no rain.
The idea
A branch is a choice between next steps. Here, expected rain means take an umbrella; no expected rain means leave it. An unknown forecast means check before deciding. You are about to go out. If rain is expected, take an umbrella. If no rain is expected, leave it at home. That simple choice is a branch: a condition on the information you have selects what happens next. A workflow is a set of such steps with predetermined paths, written in advance. An agent instead lets a model choose its next step while it runs. Both need the same care with missing inputs.
You choose the forecast and a written rule follows it. No weather service or AI model runs here. A missing forecast does not mean there will be no rain. This exercise follows a written rule using a forecast you select. It does not check the real weather or ask an AI model. Unknown is a third case: check the forecast before deciding. A missing answer is different from an answer of no. In code, a failed lookup often arrives as null or undefined. Both are falsy, so a test such as if (!rain) quietly sends a missing forecast down the no-rain branch. Match each expected value by name and give everything else its own path. More complex agent workflows need that distinction too.
Worked example: run it yourself
Two versions of the umbrella rule. The careless one has two branches, so a missing forecast becomes “leave it at home”. The careful one has a third branch for anything it does not recognize. careless() tests only for 'rain', so null, undefined and any unexpected value fall through to the else branch. careful() matches each known value explicitly and sends everything else to a pause step. That default branch is where a real workflow would report the missing input or retry the lookup.
Save it as umbrella.js and run node umbrella.js in a terminal (Node.js 18 or later), or paste it into your browser’s developer console. Download umbrella.js
function careless(forecast) {
return forecast === 'rain' ? 'Take an umbrella' : 'Leave it at home';
}
function careful(forecast) {
if (forecast === 'rain') return 'Take an umbrella';
if (forecast === 'dry') return 'Leave it at home';
return 'Forecast missing: check again before deciding';
}
for (const forecast of ['rain', 'dry', null]) {
console.log(String(forecast).padEnd(4), '| careless:', careless(forecast), '| careful:', careful(forecast));
}
Output, as printed by Node.js 25.3.0 on 3 December 2026:
rain | careless: Take an umbrella | careful: Take an umbrella
dry | careless: Leave it at home | careful: Leave it at home
null | careless: Leave it at home | careful: Forecast missing: check again before decidingTry it
Predict what both functions return for undefined, and for 'Rain' with a capital R. Then run them.
Check your answer
careless() says Leave it at home for both. careful() says Forecast missing for both. A typo in the data is not a forecast of dry weather, so it belongs on the missing path too.
Take this with you
What changed?
A workflow connects information, a decision and the next action.
Try explaining it.
If a weather service fails, should the program treat that as a forecast of no rain?
Open a possible explanation
No. An unavailable forecast says nothing about whether rain is expected. Report the missing information and check again before choosing a branch.
Choose a next step
Continue the course in order, or open the course map.