diff --git a/variables.md b/variables.md new file mode 100644 index 0000000..6a28247 --- /dev/null +++ b/variables.md @@ -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; + +``` + +