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 Foundations Strings Concatenation

Robert Bojor
PLUS
Robert Bojor
Courses Plus Student 29,439 Points

Multiple lines

Hi Jim,

You said we can't split a text on multiple lines of code in JS and the concatenation is the only solution we have... how about

var string = "First line \
Second line \
Third line";
console.log(string);

and also, for multiple lines in the output

var string = "First line \n\
Second line \n\
Third line";
console.log(string);

1 Answer

Harry James
Harry James
14,780 Points

Yes, this works fine. Further in the tutorial, Jim discusses how this is done. I think it's in the Methods bit :)