var kitchenLights = false;
kitchenLights = true;
In this example, the variable "kitchenLights" being set to "true" would indicate that the lights are on. If it was set to "false" then that would mean they are off.
It’s useful to store booleans in variables to keep track of their values and change them over time. Booleans are used as functions to get the values of variables, objects, conditions, and expressions. In fact, Booleans are critical for conditionals to work.
In your code, when you need to know whether or not a condition is being met before proceeding to the next step, the boolean function becomes your best friend. If such and such is TRUE, then do this. If it is FALSE, then do something else.
Consider something simple like making a sandwich. In your head, you will actually be going through a series of booleans and conditionals:
Do I have bread? TRUE or FALSE. If TRUE, then I can proceed to the next step of whether or not I have mustard, ham, etc. If FALSE, then I’ll need to go to the store to get some bread. And so on and so forth.