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 trialNikki Turrisi
15,095 PointsI don't understand the point of concatenating the multi-line? Isn't it a waste of code and characters?
Is it because you can organize the actual code better within js? It seems redundant to me.
3 Answers
Marcus Parsons
15,719 PointsConcatenation of multiple lines is very handy if you have strings that stretch far beyond your screen size going into a single variable, and you don't want to have to horizontally scroll for 3 minutes to see what you wrote because I certainly do not like horizontally scrolling to see anything! :D
Jonathan Grieve
Treehouse Moderator 91,253 PointsYou should feel free to format the code as you see fit. I can see why you might want to code multiline if you had something like this
var language = " javascript";
var mood = " it's great";
"I love"
+" coding in"
+ language
+ "because "
+ mood
But if you were joining together strings that were much larger, it might be easier to read if you put them one one line. :-)
Marcus Parsons
15,719 PointsTotally agree!
Kieran Kane
10,973 PointsMy understanding is that it doesn't have any benefit in the example given, but it shows you how to use it for examples like Marcus and Jonathon provided.
Mathijs Bakker
2,914 PointsMathijs Bakker
2,914 PointsAn example:
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsAbsolutely, Mathjis!