The first and most important concept in any programming language is variables.
The only tricky point is when you want to store your data for a temporary
purpose. We will be using variables. In this video we are focusing how do you
store data in a code, so we can do that with the help of variables. When you run
this code. Of course, you will get four, four because of the first operation and
the second operation, but don't you think we are doing the same thing again. the
only change is this time. You are fetching the value from a variable, so the first
fold which you got here is coming from this number okay now I can actually
reuse and that's the power right. If you want to create a variable in JavaScript.
You have an option of just by saying a variable name. You can use it by chance.
If you 're coming from other language. Let 's say C++, Java or any language
which needs you to declare variables that's right in some languages. We have to
declare them first here we are simply saying num.
We have a variable username and then we are trying to assign a name and we
got an error. See what this editor says it says Naveen is not defined that’s where
I am defined here see the problem is if you remember we have talked about this
whenever you write a code that code has to be converted into a machine code
because your computer understands only one language which is machine
language. when you want to assign a string always use double quotes, so text
string it should be inside a double quote. JavaScript says you can use both and
that’s why JavaScript is a flexible language in that case, but yeah if you are
using a double quotes at the start don't use single quote at the end, if you're
starting your programming journey, you will be facing a lot of errors as I.
mentioned before that should be a part of your life write a code get others solve
them, which is very important and the first step to solve a error is to read the
error properly.. never use a variable name which is not defining itself and that
means you have you 're declaring multiple times.
numbers are allowed and you can put numbers anywhere not the first value. The
first letter should not be a number. There are certain standards. You can follow
to name your variable so whenever you have variable which has two words.
Example, if you look at this username here, you can see there are two words,
right user and name.
DM