Using Logic in JavaScript Flashcards
(39 cards)
Which Operator would tell you which player won in a two player game?
The Comparison Operator
What is the Comparison Operator used for?
It’s used for comparing two operands, like player scores.
How many operators are there that can be used in expressions to compare two values?
4
Do the 4 expressions evaluate to a boolean data type?
Yes
What are the four operators that can be used in expressions to compare two values?
<
>
<=
>=
What is >
more than
What is <
less than
What is >=
more than or equal to
What is <=
less than or equal to
What Will the < operator resolve to?
The Less Than < Operator will resolve to true is the first operand is smaller than the second operand.
What will the > operator resolve to?
The More Than > Operator will resolve to true if the first operand is larger than the second operand.
What will >= and <= resolve to?
They will resolve to true if the first operand is equal to.
How do you check if two operands are of the same value?
Using the equality Operator ===
What is the symbol for the Equality Operator?
===
Can you use the assignment operator to compare equality in JavaScript?
No
What Data Type will using the Equality Operator in Expressions Resolve to?
Boolean
Can the Equality Operator be used to check data types in a code?
Yes it can when it is combined with the typeof operator.
What must the Equality Operator be combined with when used to check data types in a code?
The typeof Operator
What is an example of Loose Equality?
Where two values of two different data types can said to be equal, such as the string ‘five’ and the number 5.
What is the symbol for the Loose Equality Operator?
==
What are Logic Operators?
Logic Operators allow us to combine expressions and have them resolve down to one boolean data type.
How can we compare 2 expressions?
We can compare two expressions with the AND operator.
What is the symbol for the AND Operator?
&&
How do you use the AND Operator?
You place two expressions on either side of the AND Operator. It will resolve to TRUE if both expressions on either side of the AND operator resolve to true. It will resolve to FALSE if both expressions on either side of the AND operator resolve to false. It will resolve to FALSE if one side is true and the other side is false.