WDI Fundamentals

WDI Fundamentals Unit 8

By the end of this unit, you'll be able to:
  • Differentiate between true, false, "truthy", and "falsey"
  • Use if...else conditionals to control program flow based on boolean conditions
  • Use comparison operators to evaluate and compare statements
  • Create an array and add, remove, replace, and retrieve a specific element from an array
  • Use loops to repeat an operation or action based on the value of a condition.
  • Iterate over and manipulate values in an array using a for and/or while loop

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.

In this unit, we will look at how control flow is implemented in JavaScript. In particular, we'll focus on making decisions (conditionals) and repeated behavior (loops).

Let's get started.