Skip to content

Commit

Permalink
Create variables.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel (Manu) Enzeyi authored Oct 29, 2023
1 parent 55a7bb1 commit 7a21e2c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@


# Variables In JavaScript


We can easily describe variables as containers for storing data.

There are several ways through which we can define variables in javascript; either automatically or by using the var, let or const keywords.

Let us have a look at some examples:

## Automatic Declaration
In this case, the variables will get declared as variables automatically:


```bash
//Creating a variable named x and storing the value 20 in it
x=20;

//creating a variable named y and storing the value 30 in it
y=30;

//creating the variable z and storing the sum of variable x and variable y in it
z=x+y;
```
## Declaration using the var keyword

In this case we are using the var keyword

```bash
//Creating a variable named myAge using the var keyword and storing the value 27 in it

var myAge=27;
```

## Declaration using the let keyword

```bash
//Creating a variable named herAge using the let keyword and storing the value 25 in it

let herAge=25;
```
## Declaration using the const keyword

```bash
//Creating a variable named myAge, herAge and OurTotalAge and storing the sum of variable herAge and myAge in the variable OurTotalAge

const herAge=25;
const myAge=27;
const OurTotalAge=herAge+myAge;

```


0 comments on commit 7a21e2c

Please sign in to comment.