javascript string.join code example
Example 1: .join javascript
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));
Example 2: join javascript array
const cities = ['London', 'Paris', 'Tokyo'];
const joinedCities = cities.join('-');
console.log(joinedCities);
Example 3: js join
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));
Example 4: join method javascript
var array = ["Joe", "Kevin", "Peter"];
array.join();
array.join("-");
array.join("");
array.join(". ");
Example 5: javascript join address to string
var address = "foo";
var city;
var state = "bar";
var zip;
text = [address, city, state, zip].filter(Boolean).join(", ");
console.log(text)