Home » Forum

Forum

Convert an Array to...
 
Notifications
Clear all

Convert an Array to a String with Commas in JavaScript


geekfrisk
(@geekfrisk)
Member Admin
Joined: 3 years ago
Posts: 19
Topic starter  

join() method in javascript used to convert an array to a comma-separated string.

var array=["Sam","Tony","Sunny","Federal"];
array.join();

output:

"Sam,Tony,Sunny,Federal"

default it will take comm value.

 

array.join(' and ')

we can add custom string

Output:

"Sam and Tony and Sunny and Federal"


Quote
Share: