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.
The script defines a library 2D array (3 shelves × 3 items each = 9 items total) and demonstrates the following:
- 2D array with at least nine items split across shelves — declare
library. - Access and log every element using bracket notation with literal numbers — log each item via
library[row][col]. - Access using variable indices
rowanditem— nestedforloops walk the whole structure. - Loop printing only the second shelf (index 1) — iterate just
library[1].
Prerequisites: Node.js installed.
# from the project root
node index.jsYou should see every item printed three ways: by literal index, by variable index with shelf/item labels, and finally just the second shelf.