join array into string code example
Example 1: .join in javascript
const elements = ['Sun', 'Earth', 'Moon'];
console.log(elements.join());
// output: "Sun,Earth,Moon"
console.log(elements.join(''));
// output: "SunEarthMoon"
console.log(elements.join('-'));
// output: "Sun-Earth-Moon"
Example 2: javascript join list of string
// array.join(separator)
var myArray ['foo', 'bar', 'baz'];
myarray.join(':');
// foo:bar:baz
Example 3: joining array of string
Array.join()