Javascript - Creating Arrays
📖 Read the lesson
Code Life
By Pierre Marsaa
One Variable for the Whole Team
You caught three Codémon. With what you know so far, you'd need one variable per Codémon:
↗️
Loading editor...
↶
▶️ Run
↷
That gets messy fast: what about a team of 6, or a bag with 50 items? An
array
stores several values in a single variable:
↗️
Loading editor...
↶
▶️ Run
↷
One variable, three values, kept in order. Arrays are everywhere in JavaScript: teams, inventories, scores, lists of moves...
Verify