Codington
0 of 10 problems solved • 0%

Exercise prompt

Number a Packing List

An indexed loop uses a counter to visit array positions.

Example

const colors = ["red", "blue"]; for (let index = 0; index < colors.length; index += 1) { console.log(colors[index]); } // Output: // red // blue
  • index = 0 starts at the first position.
  • index < colors.length allows indexes 0 and 1. The last index is one less than the length.
  • colors[index] reads the item at the current position.

Your task

Display the supplied packing list as 1. charger, 2. notebook, and 3. bottle. Use the loop index both to read each item and create its visible number.

Hint

The array index and the number shown to a person start at different values.