- We learned how to create and store values, but how do we compare them?
- We need to compare numbers in situations like checking a user's entered PIN matches their saved PIN.
const enteredPin = 5448;
const expectedPin = 5440;
To compare if two numbers are the same, we use the equality operator, ===.
5===5
EXAMPLES
When checking if a player's number of lives remaining is exactly 5
To check if a number isn't equal to another number, we use the inequality operator, !==.
Eg: console.log(10!==11)
We can store the result of a comparison with the inequality operator in a variable.
Save the comparison between 1 and 2 into the variable result.
const result = 1 !== 2;
console.log(result);