Now that is it for functions;
we learned a couple of new features related
to functions that can sometimes be useful,
and we had a brief look behind the scenes of functions.
Now I wanna come back to one line of code
that we have here that we can also improve
with some advanced JavaScript code.
And that's this line here,
or specifically it's this part here in this line
where we are constructing that string
by combining some hard coded strings,
like the "blank" or the "exclamation mark,"
with some dynamic pieces, the values
we get here in these parameters.
We can build a string like this,
but JavaScript also has an alternative for us.
Instead of building that string like that,
and hence I'll comment it out,
we can also use a feature called Template Literals
that's built into JavaScript.
For this, we can build a string
by using backticks instead of single quotes,
and that's important.
These backtick characters here are
special characters on your keyboard;
it's not the regular single quote.
It's a special character which you'll have on your keyboard,
and you can use backticks to create a string,
like "Hi there" as we did before.
But we typically don't use backticks
to just create a regular string like that;
instead, these backticks give us some powerful features:
For one, they allow us to write multiline strings.
We can add line breaks inside of the string,
and that's not possible if we use single quotes;
if we try to do that,
we instead get some errors as you can see here.
So that's one advantage of using backticks.
But the even more useful advantage is
that you can easily plug in dynamic values into
that string without having to concatenate
and combine a lot of pieces with the plus operator.
Instead, if we wanna rebuild the string from up there,
we can just add a special syntax in here
to plug in our greetingPrefix.
We use the "$" sign and then "opening
and closing curly brace,"
and you see that this now gets highlighted by my IDE
because it's detected as a special piece of syntax.
And between those curly braces,
you can now put your variable, or constant,
or parameter value that you wanna output here,
for example, greetingPrefix.
Then you can add a white space
and maybe add another placeholder
where you plug in the username,
and then we have the "exclamation mark" thereafter.
This will construct the same kind of string we saw before.
Hence, if I execute this file,
we, again, get "Hi Max" and "Hello user,"
but it does so in a shorter, more concise way
with help of these placeholders here
where we plug in dynamic values into a string.
And that is another feature that can be useful,
especially if you are constructing very long strings
with a lot of dynamic values.
Then you can avoid having all these extra plus operators
and concatenating strings with each other,
and you can just write one string
with some dynamic values inside of that string.