Skip to main content
🟨 JavaScript Foundations

Boolean Logic

A boolean is a true/false value. Comparisons like >= produce booleans, and you can combine them with logical operators: && (and β€” both must be true), || (or β€” either one), and ! (not β€” flips it).

age >= 18 && hasTicket; // true only if BOTH hold
age < 13 || age > 65;   // true if EITHER holds

Your task

Write canVote(age, isCitizen) that returns true only when age is at least 18 and isCitizen is true.

⚑ 25 XP

🧱 Code blocks

Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.

solution.jsRuns in your browser
Loading editor…
Tests3 to pass
adult citizen
too young
not a citizen

Run your code to check these.