Categories
JavaScript Answers

How to join a JavaScript string array into a string without commas?

Spread the love

Sometimes, we want to join a JavaScript string array into a string without commas.

In this article, we’ll look at how to join a JavaScript string array into a string without commas.

How to join a JavaScript string array into a string without commas?

To join a JavaScript string array into a string without commas, we can call the array join method with an empty string.

For instance, we write:

const s = ['foo', 'bar', 'baz'].join('')
console.log(s)

to call join on the array with an empty string.

As a result, s is 'foobarbaz'.

Conclusion

To join a JavaScript string array into a string without commas, we can call the array join method with an empty string.

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 *