How to Declare a String in Multiple Lines in JavaScript?

Estimated read time 1 min read

You can declare a string in multiple lines in JavaScript using template literals (enclosed by backticks ``) or by concatenating string literals (enclosed by quotes '' or "").

Template literals:

let multiLineString = `This is line 1
This is line 2`;

Concatenating string literals:

let multiLineString = "This is line 1" + 
                      "This is line 2";

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply