Array (arr)
Collection of ordered values.
Syntax
var a = [1, 2] a.append(x) a.count
Description
Arrays are created using square brackets; indices start at 0. append adds to the end (requires var), count gives the number of elements.
Example
Loading editor…
Expected output
[1, 2, 3] 1 3
When to use?
Holding multiple values (name, score).
Common mistakes
- ⚠️ For append, the array must be defined with var (let is constant).