Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 1.03 KB

File metadata and controls

23 lines (15 loc) · 1.03 KB

Practice: Multi-Dimensional Arrays

A small Node.js practice exercise modeling a library with shelves of books and movies using a 2D array. The focus is bracket notation only — no for...of loops and no array methods like forEach for the access tasks.

What it does

The script defines a library 2D array (3 shelves × 3 items each = 9 items total) and demonstrates the following:

  1. 2D array with at least nine items split across shelves — declare library.
  2. Access and log every element using bracket notation with literal numbers — log each item via library[row][col].
  3. Access using variable indices row and item — nested for loops walk the whole structure.
  4. Loop printing only the second shelf (index 1) — iterate just library[1].

How to run

Prerequisites: Node.js installed.

# from the project root
node index.js

You should see every item printed three ways: by literal index, by variable index with shelf/item labels, and finally just the second shelf.