Lesson 3 of 5 · 7 minutes
True or false: booleans
Some questions have only two answers: yes or no, on or off. Code uses a boolean for this.
A boolean can only be true or false. Write both
without quotes. "true" is text, not a boolean.
Think of a light switch. It has two positions. A boolean works the same way. This simple type will control decisions in the next module.
A boolean has exactly two states.
Loading the editor…
Change true to false, then run it again.
Quick check
You now know the third basic type: a boolean, always either true or false.