← JavaScript

Boolean Logic

A logical operator that returns true only if both conditions on either side are true.

Understanding Boolean Logic in JavaScript

What it does: ! flips true to false or false to true. This requires both hasTicket and hasID to be true. || returns true as long as at least one side is true. JavaScript uses &&, not the word 'and'. Logical AND requires two ampersands: &&. Logical OR requires two pipe characters: ||. ! returns the reversed boolean value of isOpen. JavaScript's logical AND operator is &&, not 'and'.

Common mistakes: Use &&, not the word 'and', to combine conditions. Use ||, not the word 'or', to combine conditions.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 11–25) and word search (Modules 1–29).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does && return true only if both sides are true?
YesNo
Matches
console.log(a and b);
↓
Wrong - use && instead of the word 'and'
Applying
Meanings
Term
&&
Meaning
A logical operator that returns true only if both conditions on either side are true.
Practice
let isSunny = true;
Testing
Gaps
console.log(isSunny isWarm);
Check Answer
Spots
1console.log(a and b);
2let a = true;

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Galaxy Phoenix' badge — Orbit Champion, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does && return true only if both sides are true?
A. No
B. Yes ✓
&& requires both conditions to be true to return true.
2. Does || return true if either side is true?
A. Yes ✓
B. No
|| returns true as long as at least one side is true.
3. Is 'and' a valid JavaScript operator for combining conditions?
A. No ✓
B. Yes
JavaScript uses &&, not the word 'and'.
4. Does ! reverse a boolean value?
A. Yes ✓
B. No
! flips true to false and false to true.
5. Is a single & the same as && in JavaScript?
A. Yes
B. No ✓
Logical AND requires two ampersands: &&.

Match the Pairs

isSunny && isWarm → True only if both isSunny and isWarm are true
isSunny || isWarm → True if at least one of isSunny or isWarm is true
Reverses a boolean's value → !isOpen
Combines two conditions, requiring both to be true → hasTicket && hasID
console.log(a and b); → Wrong - use && instead of the word 'and'
console.log(x or y); → Wrong - use || instead of the word 'or'

Key Term

&&
A logical operator that returns true only if both conditions on either side are true.

Fill in the Blanks

1. console.log(isSunny && isWarm);
Hint: Type the operator that returns true only if both sides are true.
2. console.log(isSunny || isWarm);
Hint: Type the operator that returns true if either side is true.
3. console.log(!isSunny);
Hint: Type the operator that reverses a boolean value.
4. let ready = hasTicket && hasID;
Hint: Type the operator that returns true only if both sides are true.
5. let closed = !isOpen;
Hint: Type the operator that reverses a boolean value.

Spot the Error

Question 1
A console.log(a and b);
B let a = true;
C let b = false;
Line A — Use &&, not the word 'and', to combine conditions.
Question 2
A let x = true;
B let y = false;
C console.log(x or y);
Line C — Use ||, not the word 'or', to combine conditions.
Question 3
A let flag = true;
B console.log(not flag);
C console.log(!flag);
Line B — Use !, not the word 'not', to reverse a boolean.
Question 4
A let p = true;
B let q = false;
C console.log(p & q);
Line C — Use &&, not a single &, for logical AND.
Question 5
A console.log(m | n);
B let m = true;
C let n = false;
Line A — Use ||, not a single |, for logical OR.

Student with a class code? Join your class →