Logical or Boolean Operators Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Logical operators

A

Logical operators are sometimes called Boolean operators because they are typically used with Boolean
values, which are either true or false. The logical operators are: AND, OR, and NOT.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

if two variables needs to be both true
AND

A

The AND operator returns true if both operands are true, but false if one or both of the operands are false.
In JavaScript, the AND operator is indicated with two ampersands (&&).
if (num1 == 0 && num2 == 0) {…}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

if only one needs to be true,
OR

A

The OR operator returns true if either or both operands are true, but false if both operands are false. In
JavaScript, the OR operator is indicated with two vertical bars or pipes (||).
if (num1 == 0 || num2 == 0) {…}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If you want something to not do that thing
NOT

A

The NOT operator returns true if its single operand is false, and false if its single operand is true. In
JavaScript, the NOT operator is indicated with an exclamation point (!).
var gameover = false;
if (!gameover) {…}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly