It was mentioned earlier that there are data types other than strings, integers and booleans. An array is one of these. Arrays allow you to easily store multiple values together.
The syntax is to list the values separated by commas, inside square brackets:
[value1, value2, value3]
You can store any type of value inside an array: strings, numbers, booleans. You can even store other arrays, or objects (which you will learn about next).
Defining an array as a variable looks something like this:
var animals = ["tiger", "puppy", "snake", "llama"];
Pretty neat! Now you have all the animals grouped together rather than having to define them separately. You can see how many animals there are by using
If you want to refer to one specific member of the array, you can do so by using their "index number" like so.
Take a guess at which animal that will print out, and see if you're right.
animalswill print out "tiger". We don't make the rules...