Ehegh
0
Q:

javascript join list of string

// Defining an array with most datatypes ( objects have to be converted to string with JSON.stringify(obj) )
var myArray = ['String',"String",1,2.5, false, NaN, undefined]; 
// Convert the array into a string using the JS function toString();
var myString = myArray.toString();
// Logging it on the console
console.log(myString) // "String,String,1,2.5,false,NaN," (undefined values cannot be converted to strings)
1
// array.join(separator)

var myArray ['foo', 'bar', 'baz'];
myarray.join(':');
// foo:bar:baz
0
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. John
-1

New to Communities?

Join the community