concat all elements of array js 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: array concat in javascript
const letters = ['a', 'b', 'c'];
const numbers = [1, 2, 3];
const newArray = letters.concat(numbers);
// newArrat is ['a', 'b', 'c', 1, 2, 3]