join comma in javascript 1

join comma in javascript

var arr = ["Zero", "One", "Two"];

document.write(arr.join(", "));

Here is what the above code is Doing:
1. We create an array called arr.
2. We use the join() method to join the elements of the array into a string.
3. We pass the separator “, ” as an argument to the join() method.
4. We print the string to the document.

Similar Posts