Foundations

If Statements

If Statements

An if statement runs a block only when its condition is true. That makes it useful for messages that should appear in one situation but not every time.

Your task: If the draft has unsaved changes, set bannerMessage to "Unsaved changes". Log the banner message.

Prerequisites

  • variables
  • operators

Tests

  • bannerMessage is set when changes are unsaved
  • the warning is logged
  • an if statement guards the assignment
Loading...
Console

Run code to see output.