> 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/variables.md).

# variables

In this module we'll study variables.

## Description

Think of a variable as a container. Cup analogies work really well with understanding variables. They store info. We can pour liquid into a cup and change it's value. We can pour two half cups into another cup. We can pour one cup into a bigger cup and then put it into an array of cups.

## File Location

You should be located in the following file:

```
   javascript-library
        └── 0-PreWork
            └── 1-HTML-Basics
            └── 2-CSS-Basics
            └── 3-JavaScript-Basics
                02-variables.js       <----You will be working in this file in this module.
```

## Description

Variables are used to store values. They are containers for values. That's it. Let's keep it that simple for now.

## Declarations

First, they must be declared:

```javascript
    var x;
```

The name could be anything you want. You could name it `spaghetti` or `football`.

## Initialized

Then, variables must be initalized:

```javascript
    x = 5;
```

Initialization is used for stating what the value of that variable is holding, as well as its type. (More on types later).

## Declarations and Initializations

You can also do it all in one statement:

```javascript
    var theNumberFive = 5;
```

## Variables Demo

Variables Demo

```javascript
var x = 1;
console.log(x);
```

## Assignment

It is common to assign a value to a variable. Then use that variable to stand for that think: Consider the following:

```javascript
const feetInMile = 5260;
console.log(feetInMile);
```

## Naming

We can name variables anything we want. This means that there is room for creative writing in software:

```javascript
var ageOfMyOldestFerret = 40;
var numberOfEggsInOneSitting = 50;
```

The variables should be sensibly named though, and able to be understood by fellow developers.

## Camel Casing

Variable names, in most cases, should be camel cased. This means that the first word is lower case and each consecutive word is upper case. It has humps like a camel. Consider the following examples:

```javascript
var numberOfGrammysIHaveWon = 0; 
var myBirthYear = 1976;
var newNumber = 1 * numberOfGrammysIHaveWon;
```

## Think it Through

Think through the answer for each one of the problems below:

```javascript
var age = 40;
var ageInAugust = age + 1;  
console.log(ageInAugust);//What will you get here?

var eleven = 11;
console.log(eleven * eleven); //What will the answer be?

var nineteen = 19;
console.log(age - nineteen); //What will the answer be?
```

## A FEW DON'TS

You can't start a variable with a number:

```javascript
var 2nite = "Tonight"
//console.log(2nite); //won't work.
```

## Reserved Words

There are exceptions for naming variables. The following list is a group of reserved words in JavaScript, and they should not be used as variable names:

| Reserved Word List |            |            |              |
| ------------------ | ---------- | ---------- | ------------ |
| abstract           | else       | instanceof | super        |
| boolean            | enum       | int        | switch       |
| break              | export     | interface  | synchronized |
| byte               | extends    | let        | this         |
| case               | false      | long       | throw        |
| catch              | final      | native     | throws       |
| char               | finally    | new        | transient    |
| class              | float      | null       | true         |
| const              | for        | package    | try          |
| continue           | function   | private    | typeof       |
| debugger           | goto       | protected  | var          |
| default            | if         | public     | void         |
| delete             | implements | return     | volatile     |
| do                 | import     | short      | while        |
| double             | in         | static     | with         |


---

# 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/variables.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.
