Explore Booleans
Booleans
Let's explore our last data type for this section, booleans.
Explore:
- Guess what the types of each of these pieces of data are before running the code.
// Let's look at examples of our three types: strings, numbers, and booleans.console.log(typeof "Hello, world!");console.log(typeof 293);console.log(typeof true);console.log(typeof false);// Note that when number, true, or false are surrounded by quotes that it is a string.console.log(typeof "true");console.log(typeof "293");
Comparison operators
Let's see how to compare two pieces of data.
Explore:
- Try different numbers for a and b.
- Try one variable being a number wrapped in quotes.
// Here are all the comparison operators// Three of these will return true with a = 7 and b = 7. Guess which ones!let a = 7;let b = 7;console.log(a === b);console.log(a !== a);console.log(a < b);console.log(a > b);console.log(a <= b);console.log(a >= b);