Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics Working with Strings Combine Strings

If you combine values that contain strings, is that still called concatenation?

At the end, the speaker mentioned that combing strings together is called concatenation, then states you can combine variables that contain strings – it was unclear if the latter is also considered concatenation.

1 Answer

Douglas Counts
Douglas Counts
10,060 Points

Yes, concatenation is appending one string to another regardless of how you do it.

Both contrived examples below are concatenation:

console.log('string one' + ' plus ' + 'string two');

const string1 = 'string one';
const plus = ' plus ';
const string2 = 'string two';

console.log(string1 + plus + string2);

Both console.log() statements contain string concatenations.

Hope you find this helpful,

-Doug