| Examples | ||
|---|---|---|
| Numbers | Strings | Booleans |
| 123 | "hello" | true |
| 0 | "I like bananas" | false |
| -73.2 | "I'm hungry" | |
| 0.017 | 'watermelon' | |
| 90000 | ":)" | |
Booleans can only be true or false -- nothing else.
They may seem a little odd, but they're particularly useful in if statements and while loops.
In fact, we frequently end up with a boolean from comparing a couple of non-booleans. Consider the following code fragement:
|
|