> For the complete documentation index, see [llms.txt](https://eleven-fifty-academy.gitbook.io/javascript-100-prework-gitbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eleven-fifty-academy.gitbook.io/javascript-100-prework-gitbook/javascript-library/0-prework/4-js-basics/arrays.md).

# arrays

In this module we'll study arrays.

## Location Check

Let's get you where you gotta be:

```
            └── 3-JavaScript-Basics
                08-arrays.js       <----You should be working here.
```

## Description

An array is a numerically indexed map of values. Starting out, it's easier to just say it's a great way to collect a bunch of values together. They allow us to collect things like names, usernames, product names, prices, etc.

## Sample Code

Add these arrays to the file:

```javascript
var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
var raceWinners = [33, 72, 64];
var myFavoriteThings = ['Broccoli', 46074, 'Zombie Cats From Mars'];
```

Take a minute and think about this:

*Read the above examples, what do you think are some general rules about arrays?*

## Key Points

Here are some key points:

* An array is created like a variable.
* It can be named anything.&#x20;
* We use square brackets `[]` to collect values.
* We separate items with commas in the brackets.
* We can have a collection of one type(6 strings that are zombie movies).
* We can also collect multiple types:&#x20;

```javascript
var mySecretSpyInfo = ["James Bond", 007, true];
```

## The 0 index

An important fact that everybody learns when they first start coding:

*The index of an array starts at 0*

Check it out:

```javascript
                    //0        1        2
var countryArray = ["USA", "Russia", "China"];
```

## Access Values

You can access arrays using bracket notation \[]. Print some of these array values by naming the array and then naming the index position:

```javascript
console.log(countryArray[2]);  //what will print here?
console.log("Country Array:", countryArray[0]); //And here?
```

## More Practice

Write four different arrays that have 4 values. Print four of the values in console statements. Try this:

* Print the first value of the first array. Remember 0!
* Print the second value of the second array.
* Print the third value of the third array.
* Print the fourth value of the fourth array.&#x20;

If you can't get that, just create some arrays and print what you can. Just play around and figure out what you can. There are also some great ways to go learn online. Just Google it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eleven-fifty-academy.gitbook.io/javascript-100-prework-gitbook/javascript-library/0-prework/4-js-basics/arrays.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
