WDI Fundamentals Unit 8
false, "truthy", and "falsey"
if...elseconditionals to control program flow based on boolean conditions
Programming is the practice of writing a set of instructions for our computer to execute. These are interpreted by our computer one at a time, in order. Sounds kind of like a recipe, right?
Suppose, however, that we are trying to cook something complicated. For example, consider the following excerpt from "French Toast à la GA:"
3) Whisk eggs, milk, honey, and kosher salt until eggs are no longer visible.
4) Dip your bread slices in the custard. If you're using a pre-sliced loaf and the slices are thin, a short dip (just enough to coat both sides) should be enough. However, if your slices are thick, you may want to give the bread a minute or two to soak up the custard.
5) Transfer the slices to your frying pan and cook on a medium-low heat until brown on the bottom.
Instructions like these require the cook to make decisions based on available data. For example, if the cook is using thin slices of bread, they should follow one set of instructions and if the cook is using thick slices, they will follow a separate set of instructions.
In the context of programming, this is called control flow, because it specifies the flow of the computer's actions through the program.
Watch this video to discover more about the role control flow plays in development.