How to break a string across more than one line of code in JavaScript?

Sometimes, we want to break a string across more than one line of code in JavaScript.

In this article, we’ll look at how to break a string across more than one line of code in JavaScript.

How to break a string across more than one line of code in JavaScript?

To break a string across more than one line of code in JavaScript, we can use template strings.

For instance, we write

alert(`Please select file   
to delete`);

to show an alert box with

Please select file   
to delete

in it.

The whitespaces and new lines are kept by template strings.

Conclusion

To break a string across more than one line of code in JavaScript, we can use template strings.