Categories
JavaScript Answers

How to join two strings with a comma and space between them with JavaScript?

Spread the love

Sometimes, we want to join two strings with a comma and space between them with JavaScript.

In this article, we’ll look at how to join two strings with a comma and space between them with JavaScript.

How to join two strings with a comma and space between them with JavaScript?

To join two strings with a comma and space between them with JavaScript, we can use the array’s join method.

For instance, we write:

const strings = ["a", "b", "c"];
console.log(strings.join(", "));

to join the strings in strings with a comma and a space.

Therefore, the console log logs 'a, b, c'.

Conclusion

To join two strings with a comma and space between them with JavaScript, we can use the array’s join method.

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 *