Categories
JavaScript Answers

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

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *