Lesson 4 of 4 · 9 minutes

Combining conditions: and / or

A decision can depend on more than one thing. Logical operators combine conditions.

&& means and: both conditions must be true. || means or: at least one must be true.

For age >= 13 && age <= 19, 13 and 19 count. But 12 and 20 do not. Check the edge values carefully. That is where many mistakes hide.

Overlapping circles show that and needs both conditions while or accepts either

And means both. Or means either.

Loading the editor…

Test 13, 12, 19, and 20. Watch where the output changes.

Quick check

When is && true?

Choose one answer.

With age >= 13 && age <= 19, does age 19 count?

Choose one answer.

You can now combine conditions with and and or — and you know to watch the edges.