An array is a container that holds many items.
When to use
Anytime you need to contain many items, use an array.
Arrays look like this:
var pizza = ["Hamburger", "Cheese", "Mushroom"];
To call an item in the array, we reference its index number:
Index numbers start with 0.
We can find out how many items are in an array:
We can sort an array alphabetically:
To add more items to an array, use:
Hints & tips
- Arrays are containers that can hold many things
- Index numbers start at 0
- pizza.length to get the length of an array
- pizza.sort() to sort an array
- pizza.push("Add something") to add an item
Lesson notes are only available for subscribers.