1var cars = ["Volvo", "BMW", "Audi", "Chevrolet"];
2console.log(cars.toString());
3//Output: Volvo,BMW,Audi,Chevrolet
1//Use array.join(separator) //
2const myArray = [1, 2, 3, 4, 5, 6];
3console.log(a.join('/'));
4//output : 1/2/3/4/5/6
5const myArray = ['g', 'o', 'o', 'g', 'l', 'e'];
6console.log(a.join(''));
7//output : 'google'
8// Source : https://www.geeksforgeeks.org/javascript-array-join-method/#:~:text=Below%20is%20the%20example%20of%20the%20Array%20join()%20method.&text=The%20arr.,is%20a%20comma(%2C%20).
9
10//Other function : array.toString() //
11const array1 = [1, 2, 'a', '1a'];
12console.log(array1.toString());
13// output: "1,2,a,1a"
14// Source : https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Array/toString
1const cities = ['London', 'Paris', 'Tokyo'];
2const joinedCities = cities.join();
3
4console.log(joinedCities); // London,Paris,Tokyo
5