All right.
So in this module, we're going to cover strings in more detail and we're going to fully get to grips
with this particular primitive data type.
So previously we saw that we can combine strings using the plus sign,
and this creates a single string using a special feature of programming called concatenation.
Now you have to imagine that you're joining together everything that's inside a quotation mark and ignoring
everything else.
So "a" + " " + "b" becomes "a b" concatenated into a single string.
Now let's try it out in practice. If we head over to Chrome and we open up our Developer Tools and we
head over to our Sources and our Snippets,
then we can start writing some code inside our index.js. So we can create an alert that says "hello"
+ "world".
And this, when we run it, will show helloworld with no spaces in between. So we can add the space by either
including it inside a string, so a string with a single space,
and this would be "hello world",
or we can have it where we have a "hello" + " world", and remember that it's only the parts that are
inside the quotation marks that are combined.
All right. So this is pretty easy.
So I want to set you the challenge of creating a greeting message using variables and alerts.
So I want you to start off with two variables.
One is a message which is equal to "Hello", and the other variable is called name,
and you can set it to either your name, or you can set it to whatever the user enters in a prompt.
Then I want you to write a single line of code where you can create a pop-up or an alert that says something
like... that combines or concatenates these two variables into a single string using these two variables
rather than simply just typing the string out.
So pause the video and complete this quick challenge.
All right.
So that's pretty easy.
All we need to do is to create an alert.
We add the message.
Then we add some characters in between, so namely it'll be
"Hello there",
(space) and then we add the name that we are going to greet.
And finally we close off our alert.
Now, the important thing here is that you remember to add the spaces between the message and the name
variables.
You could have done it this way or you could add another string that's simply a space as well.
So did you get that right?
If not, have a review of this lesson and have a play around with concatenation inside the Chrome Developer
Tools. And in the next lesson we're going to cover another cool feature of strings which is how we can
quickly find out the number of characters that are contained inside a single string.
So for all of that, I'll see you on the next lesson.