Boolean Logic, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
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.
PREVIOUS · MODULE 11Comparison Operators
YOU ARE HERE · MODULE 12Boolean Logic
NEXT · MODULE 13Truthy and Falsy Values
What students will learn in this module
Every question in Module 12
Quick questions
- Does && return true only if both sides are true?ANoBYes
- Does || return true if either side is true?AYesBNo
- Is 'and' a valid JavaScript operator for combining conditions?ANoBYes
- Does ! reverse a boolean value?AYesBNo
- 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 doesisSunny || isWarmMatch it to what it doesReverses a boolean's valueMatch it to what it doesCombines two conditions, requiring both to be trueMatch it to what it doesconsole.log(a and b);Match it to what it doesconsole.log(x or y);Match it to what it doesFill in the blanks
console.log(isSunny __ isWarm);
Hint: Type the operator that returns true only if both sides are true.
console.log(isSunny __ isWarm);
Hint: Type the operator that returns true if either side is true.
console.log(_isSunny);
Hint: Type the operator that reverses a boolean value.
let ready = hasTicket __ hasID;
Hint: Type the operator that returns true only if both sides are true.
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;
