how to turn array into string code example

Example 1: javascript array to comma separated string

var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"

Example 2: js array to string

var myArray = ['no','u'];
var myString = myArray.toString();

Example 3: .join in javascript

const elements = ['Sun', 'Earth', 'Moon'];

console.log(elements.join());
// output: "Sun,Earth,Moon"

console.log(elements.join(''));
// output: "SunEarthMoon"

console.log(elements.join('-'));
// output: "Sun-Earth-Moon"

Example 4: array to string java

char[] charArray = new char[] {'b','u','z','z'};

String answer = new String(charArray);

Example 5: array to string javascript

<array>.join(<splitting character(s)>);

Example 6: turn array into 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"

Tags:

Php Example