Array JavaScript ke string yang dipisahkan koma
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"
Grepper
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"
var array = string.split(',');
let numbers = [0, 1, 2, 3];
let numbersToString = numbers.toString();
console.log(numbersToString);
// output is "0,1,2,3"
const selectedPlaces=[
{ name: 'Stockholm', isChecked: true },
{ name: 'Dubai', isChecked: true },
{ name: 'San Francisco', isChecked: 'false' },
]
const tempSelectedPlace = selectedPlaces.filter(place => place.isChecked === true);
//[{ name: 'Stockholm', isChecked: true },{ name: 'Dubai', isChecked: true },]
const selectedPlace = tempSelectedPlace.map(place => place.name).join(', ')
console.log(selectedPlace)
//Stockholm,Dubai