Skip to content

Latest commit

 

History

History

js-control-flow

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Control Flow

Objectives

  • Describe the benefits of altering control flow in JavaScript
  • Use boolean statements to return true and false values
  • Utilize if/else statements in order to skip blocks of code
  • Identify truthy and falsey values
  • Utilize for, for...in, and while loops to loop through data structures and repeat code

Control Flow

Control flow is the order in which the computer executes statements in a script. Javascript executes top-to-bottom, unless we alter the control flow.

Why/how would we alter the control flow? 1. Skip lines of code based on a condition. 2. Repeat lines of code when traversing a data set or just for the sake of DRY code.

What kinds of statements do you remember from the prework that changed control flow?

Here are some statements we can use to alter the control flow: 1. if 2. switch 3. while 4. for 5. for...in

But before that, let's create the expressions needed for these statements.