Now, before we dig deeper into variables
and different values and what we can do,
let's talk about the general syntax of all of that again.
You've learned about some important syntax features
and rules already.
For example, that there must be a white space after let
and that let is a special keyword in JavaScript,
which we can use to instruct the browser
to create a variable.
We learned that we then can store a value
with help of the equal sign in that variable and,
very important for that variable name,
that it must not contain any blanks or special characters
and that we therefore typically use this convention
for giving it a name.
The difference between a rule and a convention
is that a convention is not a must to do,
a rule on the other hand is.
So it's a rule to not have blanks,
but a convention to then use this camelCase notation
for assigning that name.
You could also set it to greeting texts like this,
starting with a capital G, that would be valid,
it would not violate any rules,
but it would be against this convention.
So that's why I'm following it with a lowercase G.
Now another syntax feature,
which you will see in a lot of JavaScript code,
including my JavaScript code from now on
is that lines end with a semi colon.
It's actually not a must to do,
as you can clearly tell by the fact
that this code worked without issues,
but it is something which is often done.
It's done to clearly mark, where a line of code ends.
Now, of course you could say, well,
obviously the line ends where it ends,
but theoretically, in JavaScript,
you are allowed to have multiple commands in one line,
but without a semi-colon you would get an error,
as you can tell.
If I add a semi-colon here, that would work again.
Now it's not considered a good practice
to put multiple instructions into one line though.
And therefore you typically should split them across
multiple lines and hence,
you can omit semi-colons.
Nonetheless, since we must use semi-colons
in many other programming languages,
and since you must use them in JavaScript
if we had multiple instructions in the same line,
it's often seen that people do use semi-colons
after every line,
even if they do split their code
across multiple lines correctly.
And it's also something, a certain programming style,
which I like to follow and therefore,
I also put semi-colons at the end of each line,
but it's technically not required
and you don't have to do it,
but if you don't do it, you should never do it.
So again, be consistent, just as with the quotes.
You can create strings
with double or single quotes around them,
but you should be consistent once you've made a decision.
And here I will be consistent
and I will be using semi-colons
at the end of every code line.