Arrays

Array Length

Array Length

The .length property tells you how many items are currently in an array. Because it is a number, you can compare it with another number and store the answer as a boolean.

That pattern shows up in menus, notifications, and search results where the page shows only part of a longer list.

Your task: Use visibleAlerts.length and maxVisible to create hasHiddenAlerts. The value should be true when the alert list is longer than the visible limit. Log the boolean.

Prerequisites

  • variables
  • arrays
  • operators

Tests

  • hasHiddenAlerts is true when the list is longer than the limit
  • the comparison uses the array length
  • the boolean result is logged
Loading...
Console

Run code to see output.