Categories
JavaScript Answers

How to create string with multiple spaces in JavaScript?

Spread the love

Sometimes, we want to create string with multiple spaces in JavaScript.

In this article, we’ll look at how to create string with multiple spaces in JavaScript.

How to create string with multiple spaces in JavaScript?

To create string with multiple spaces in JavaScript, we use &nbsp.

For instance, we write

const str = "hello" + "&nbsp &nbsp &nbsp &nbsp &nbsp" + "world";

to add 5 spaces to the str string with "&nbsp &nbsp &nbsp &nbsp &nbsp".

Conclusion

To create string with multiple spaces in JavaScript, we use &nbsp.

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 *