bhylu.com

Advertisements

JS Control Flow

Control flow is the path taken through statements. Trace conditions and return points with a small input.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

function canBook(places) {
  if (places <= 0) return false;
  return true;
}
console.log(canBook(0));

What happens

The first return ends the function and produces false.