// join an array together into a string
// array for the .join() method
let numbers = [3, 1, 6]
let string = numbers.join(', ') // returns '3, 1, 6'
// Also works the same just for an array of STRINGS
const myNewString = myArray.join(',');
myNewString;
const cities = ['London', 'Paris', 'Tokyo'];
const joinedCities = cities.join();
console.log(joinedCities); // London,Paris,Tokyo
// convert an array to string javascript
// using reduce()
let array = ['A', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'];
let output = array.reduce((a, b) => a + ' ' + b);
console.log(output); //A quick brown fox jumps over the lazy dog
// using join()
let output1 = array.join(" ");
console.log(output1); //A quick brown fox jumps over the lazy dog
const atrArr = ['7', '2', '5']
let numbersArr = strArr.map(c => +c); //[7, 2, 5]
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
/* You can use map and pass the String constructor as a function,
which will turn each number into a string: */
sphValues.map(String) //=> ['1','2','3','4','5']