Boolean Logic, online

Six activities your students do on their own devices. See who's finished, and their scores.

Boolean Logic in one minute

What students need to know

! 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'.

Mistakes students make

  • Use &&, not the word 'and', to combine conditions.
  • Use ||, not the word 'or', to combine conditions.
  • Use !, not the word 'not', to reverse a boolean.
  • Use &&, not a single &, for logical AND.

Discover other journeys with this module

What students will learn in this module

Every question in Module 12

Quick questions

  1. Does && return true only if both sides are true?ANoBYes
  2. Does || return true if either side is true?AYesBNo
  3. Is 'and' a valid JavaScript operator for combining conditions?ANoBYes
  4. Does ! reverse a boolean value?AYesBNo
  5. Is a single & the same as && in JavaScript?AYesBNo

Key terms

Students type the meaning of:

  • &&

Match the pairs

isSunny && isWarmMatch it to what it does
isSunny || isWarmMatch it to what it does
Reverses a boolean's valueMatch it to what it does
Combines two conditions, requiring both to be trueMatch it to what it does
console.log(a and b);Match it to what it does
console.log(x or y);Match it to what it does

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

Aconsole.log(a and b);Blet a = true;Clet b = false;

Question 2

Alet x = true;Blet y = false;Cconsole.log(x or y);

Question 3

Alet flag = true;Bconsole.log(not flag);Cconsole.log(!flag);

Question 4

Alet p = true;Blet q = false;Cconsole.log(p & q);

Question 5

Aconsole.log(m | n);Blet m = true;Clet n = false;