JavaScript code to combine array elements into string. code example
Example 1: .join javascript
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
// expected output: "Fire,Air,Water"
console.log(elements.join(''));
// expected output: "FireAirWater"
console.log(elements.join('-'));
// expected output: "Fire-Air-Water"
Example 2: javascript join list of string
// array.join(separator)
var myArray ['foo', 'bar', 'baz'];
myarray.join(':');
// foo:bar:baz