This is where we left in the previous video by explaining the syntax for writing JavaScript variables.
In this video, let's get back to Visual Studio code and put them into code.
I'm going to create a folder called Variables and I'm going to name this one according to the sections
of this course.
So here I'm going to name it as variables and you can name it whatever you want.
And inside I'm going to create one HTML file and that is index dot HTML and let me scaffold it.
And here I'm going to add H1 by saying JavaScript variables.
And last step is I'm going to add the JavaScript file as script dot JS and I'm going to link up the
JavaScript and I can use the script tag inside the head by using defer and that is what I'm going to
use.
So let me rename the title here as that and it's going to be a script and as we see.
Dot script dot JS and I'm going to add defer.
This is what we explained in the previous video how to connect or include JavaScript in HTML.
So now let me collapse this one and this is my JavaScript file and let me open inside the browser and
it has opened here as that and let me open the console right click inspect and there we go.
And you can change the position of the console by clicking on this icon here and here you can toggle
whether it should be below or on the other side.
All right.
So here we go.
Let me close this once and have something like this and let me reload.
Great.
So now let's go ahead and explore more.
So inside the script file, we are going to create our first variable.
And it goes like this.
It starts with the const.
That is a keyword.
So here we can begin with const or let or var.
In this case, we are going to save a name of a person inside our application.
So it goes like this.
So here I'll add a comment by saying variable declaration and for this we can begin using the let keyword
or var or const.
I will show you when to use one of these.
So the whole logic here is that we are going to save an age of a person inside our application and I'm
going to use Var for this and it follows the name of the variable and I will say age and I will assign
to the value, let me say 20.
Great.
So now if you go ahead and console log the age, we're going to have the value of 20, meaning that
we have saved 20 inside the age and JavaScript internally have saved this variable.
So if I save this file and back to Chrome and if I make use of age now, let's see.
Now, as you can see, we have 20 meaning that JavaScript internally have saved the value that we have
declared in its internal memory.
And again, I can go ahead and console log the age and inside the console here.
Let me refresh it.
As you can see, we have the 20 down here.
Let me remove the one that we just did.
And if I refresh it, as you can see, we have 20 and I can declare a variable, let's say let and I'm
going to use, let's say, money and is equal to $100.
And if I console dot log the money here, we're going to have $100 and I can use const, let me say
const and I will say city is equal to Kumar C for string.
Put them inside quote and I will show you how we can declare variables in the recommended ways.
All right.
So with this one, if I save it and console log the city.
Now let's have a look.
And indeed we have it down here.
Great.
So, guys, this is how we declare a variable.
The takeaway here is that no, the keyword and then the variable name and then the value.
Don't worry, we're going to have best practices for declaring variables.
And this is the starting point.
Let's continue in the next video.