JS Coding Questions Logo
JS Coding Questions
#311💼 Interview💻 Code

How do you write multi-line strings in template literals

Advertisement

728x90

In ES5, you would have to use newline escape characters('\\n') and concatenation symbols(+) in order to get multi-line strings.

javascript
1console.log("This is string sentence 1\n" + "This is string sentence 2");

Whereas in ES6, You don't need to mention any newline sequence character,

javascript
1console.log(`This is string sentence
2  'This is string sentence 2`);

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 55

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
311of476
How do you write multi-line strings in template literals | JSCodingQuestions.com