FAQ: Introduction to JavaScript - String Concatenation

This community-built FAQ covers the “String Concatenation” exercise from the lesson "Introduction to JavaScript ".

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise String Concatenation

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

6 posts were split to a new topic: Why doesn’t the text match the question?

3 posts were split to a new topic: Why would we use string concatenation?

2 posts were split to a new topic: Why would we use string concatenation?

6 posts were split to a new topic: Can a space be at the beginning or end of a string?

2 posts were merged into an existing topic: Why would we use string concatenation?

2 posts were merged into an existing topic: Why would we use string concatenation?

What does this mean?

Use string concatenation to concatenate a string with a space ' ' between the two other words: Use the + operator to join three separate strings:

console.log(‘string1’ + ’ ’ + ‘string2’)

I can’t get past this point. What do I do?

1 Like

Consider,

console.log(‘Hello’ + ‘World’)

versus,

console.log(‘Hello’ + ’ ’ + ‘World’)

Now in a dynamic environment,

a = 'Hello'
b = 'World'
console.log(a + b)
console.log(a + ' ' + b)
2 Likes

Thank you for the reply. Should I be using a dynamic environment? How do i do that? I’m still not sure what the difference is between these except just being two different ways to write the same thing? How do i know when to use the right thing?

1 Like

ok i’m at wits end with lesson 6/10 i’m stuck like chuck someone please help me with JS 6/10 please. I’m stuck where it states that i have to use the concatenation string with using a space i did what its telling me without any red error but still no green check mark either. Please help. Thanks

Perhaps you can share a screenshot of your code OR copy paste your code here (code would be just two lines) so that we can spot any issues.
In the second step of the exercise, you will be concatenating three strings together (the second string will be a string with a single space i.e. ' ' ) . The hint also shows how to accomplish this. If it still doesn’t work, then perhaps a screenshot or copy/paste of your code may reveal some clues.

1 Like


I figured it out!!! Thanks for replying I was getting frustrated but i was so focused and determined in figuring it out on my own. That’s what I love about codecademy. So it was so simple can’t believe it took me so long but finally got it. I simply just added a space after Hello and another space after the last string!!!

1 Like

there are two ways to fix this. The first one (which i believe codecademy wants you to do) is to leave a space after the first string OR before the second string. Ie, below:
console.log('Hello '+ ‘World’); OR // Notice the space after the o in the ‘Hello ’
console.log(‘Hello’+ ’ World’); // Notice the space before the W in the ’ World ’

the second one is what i believe you are trying to do.
console.log(‘string1’ + ’ ’ + ‘string2’); //it will work fine in any code editor, Just press the space key on your keyboard to create space between the empty quote : ’ ’