javascript how to join arrays code example
Example 1: .join in javascript
const elements = ['Sun', 'Earth', 'Moon'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));
Example 2: can you do a join() in js without the commas
arr.join("")
Example 3: combine 2 arrays javascript
const itemsA = [ 'Lightsaber', 'Mockingjay pin', 'Box of chocolates' ];
const itemsB = [ 'Ghost trap', 'The One Ring', 'DeLorean' ]
const allItems = [ ...itemsA, ...itemsB ];
Example 4: js combine two arrays
const letters = ['a', 'b', 'c'];
const numbers = [1, 2, 3];
letters.concat(numbers);