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.