Combine Conditions with AND
Fill in the Blank Easy
Question
Fill in the blank so the code runs only when age is at least 18 AND has a license.
Code
let age = 20;
let hasLicense = true;
if (age >= 18 ___ hasLicense) {
console.log("Can drive!");
}
Hint
AND requires both sides to be true.
Explanation
The && (AND) operator requires both conditions to be true. age >= 18 && hasLicense is true only when the person is at least 18 AND has a license. Using || (OR) would allow driving with just one condition being true, which is not the desired logic.
Related Resources
Related Lessons
- Boolean Logic
Learn about boolean logic and operators.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.