Arrays

Lesson 7 of 20

Store ordered lists of values, grab anything by index, push new items on and walk everything with each.

The big picture

One variable, many values

An array is an ordered box of values in a single variable — the everyday workhorse for lists of anything.

Ordered lists

An array keeps its values in order: ["apple", "banana", "cherry"].

Zero-based index

fruits[0] is the first item — counting starts at zero, not one.

Grow with push

fruits.push("date") appends to the end; length reports how many you have.

each walks it all

One block pass per element, in order — the friendliest way to visit everything.