Interactive control flow

Which branch actually runs?

Set each condition to true or false. Execution stops at the first true branch — exactly as it does in code.

01Build the chain

elseFallback branch

02Follow execution

What the visualizer is showing

An if / else-if chain is ordered. The runtime checks conditions from top to bottom and enters only the first branch whose condition evaluates to true. Every later condition is skipped — even when it would also be true.

That makes order part of your program's meaning. Put narrower, exceptional cases before broader cases. If you test score >= 50 before score >= 90, a score of 95 reaches the first branch and the distinction for 90-plus is lost.

When to choose something else

Use guard clauses when each branch exits early, a lookup object when exact values map directly to results, or polymorphism when the branch grows because each type has different behaviour. The goal is not to eliminate conditionals; it is to make the decision obvious.