To join the elements of a array to a string in JavaScript you can use the following snippet.

Sample Javascript

var days = ["Monday", "Tuesday", "Friday"];
var joinedDays = days.join(" and ");

Result

Monday and Tuesday and Friday

for more informations take a look at W3Schools JavaScript Array join() Method

One thought on “How to join the elements of a array to a string in JavaScript”

Leave a Reply