.join javascript

JavaScript
const winners = ["George", "Tim", "John"];
const orderedList = winners.map((w, i) => `${i + 1}. ${w}`);

console.log(order.join("\n"));
// expected output:
// 1. George
// 2. Tim
// 3. Johnvar fruits = ["Banana", "Orange", "Apple", "Mango"];

var energy = fruits.join();
 //comma separated string into array
var colorsString="red,green,blue";
var colorsArray=colorsString.split(","); //split colorsString into array;
//console.log(colorsArray); ["red", "green", "blue"]var address = "foo";
var city;
var state = "bar";
var zip;

text = [address, city, state, zip].filter(Boolean).join(", ");
console.log(text)//turns array to string

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"
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"
Source

Also in JavaScript: