Using Logic in JavaScript Flashcards

(39 cards)

1
Q

Which Operator would tell you which player won in a two player game?

A

The Comparison Operator

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

What is the Comparison Operator used for?

A

It’s used for comparing two operands, like player scores.

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

How many operators are there that can be used in expressions to compare two values?

A

4

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

Do the 4 expressions evaluate to a boolean data type?

A

Yes

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

What are the four operators that can be used in expressions to compare two values?

A

<
>
<=
>=

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

What is >

A

more than

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

What is <

A

less than

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

What is >=

A

more than or equal to

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

What is <=

A

less than or equal to

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

What Will the < operator resolve to?

A

The Less Than < Operator will resolve to true is the first operand is smaller than the second operand.

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

What will the > operator resolve to?

A

The More Than > Operator will resolve to true if the first operand is larger than the second operand.

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

What will >= and <= resolve to?

A

They will resolve to true if the first operand is equal to.

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

How do you check if two operands are of the same value?

A

Using the equality Operator ===

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

What is the symbol for the Equality Operator?

A

===

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

Can you use the assignment operator to compare equality in JavaScript?

A

No

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

What Data Type will using the Equality Operator in Expressions Resolve to?

17
Q

Can the Equality Operator be used to check data types in a code?

A

Yes it can when it is combined with the typeof operator.

18
Q

What must the Equality Operator be combined with when used to check data types in a code?

A

The typeof Operator

19
Q

What is an example of Loose Equality?

A

Where two values of two different data types can said to be equal, such as the string ‘five’ and the number 5.

20
Q

What is the symbol for the Loose Equality Operator?

21
Q

What are Logic Operators?

A

Logic Operators allow us to combine expressions and have them resolve down to one boolean data type.

22
Q

How can we compare 2 expressions?

A

We can compare two expressions with the AND operator.

23
Q

What is the symbol for the AND Operator?

24
Q

How do you use the AND Operator?

A

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.

25
What will the OR Operator Resolve to if one of the expressions is true?
If at least one of the expressions is true, the OR Operator Resolves to True.
26
What is the syntax for the OR Operator?
||
27
What would true || true resolve to?
true
28
What would true || false resolve to?
true
29
What would false || true resolve to?
true
30
What would false || false resolve to?
false
31
What is the Bang Operator?
The Logical Operator for NOT
32
What is the syntax for the Bang Operator?
!
33
Why is it called a Bang Operator?
Because the punctuation ! is often referred to as a Bang in American English
34
What happens when a Bang Operator is used before a Boolean?
The expression will evaluate to the opposite of the boolean
35
What would this resolve to? !true //
It would resolve to false
36
What would this resolve to? !false //
It would resolve to true.
37
Which Operator can we use to check if two values are not equal?
We can use the strict inequality operator
38
What is the symbol for the strict inequality operator?
!==
39