Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Practice: Indices and Bracket Notation

A small Node.js practice exercise modeling a simple cafe order system to reinforce JavaScript array fundamentals: indices, bracket notation, .length, dynamic access via variables, looping, and mutating arrays with .push().

What it does

The script maintains two arrays — drinks and pastries — and demonstrates the following concepts in order:

  1. Create the order arrays — declare drinks and pastries.
  2. Log counts using .length — print how many items are in each array.
  3. Access orders with bracket notation — combine items by hardcoded index (first/last/second).
  4. Access orders dynamically with variables — use drinkIndex and pastryIndex to pick items.
  5. Loop logging every drink using .length — iterate the drinks array with a for loop.
  6. Add a new order and re-track length.push() a new drink and read the updated length.

How to run

Prerequisites: Node.js installed.

# from the project root
node index.js

You should see output covering each task, ending with the newly added drink.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages