Boolean Values
We said that all conditions ultimately are either true (true
) or false (false
). We can verify this by printing the condition:
console.log(10 < 20); // Prints: true
const condition = 10 > 10;
console.log(condition); // Prints: false
The values true
(true) and false
(false) are called Boolean values. We can also use these values directly in the code. For example:
const condition = true; // True
if (condition) {
console.log("This is always printed");
}
And we can also compare them:
true === true // True
true === false // False
true !== false // True
This may not seem very useful now, but later you will see that Boolean values are indeed very useful.
Instructions
Create a variable discount
with the value true
.
If discount
is true, print I will buy!
.
Start programming for free
4/9