var colors = ["red", "blue", "green"]; var colorsString = colors.join(","); //"red,blue,green"
Here is what the above code is Doing:
1. We create an array called colors.
2. We create a variable called colorsString.
3. We use the join() method to join the elements of the colors array into a string.
4. We separate each element in the string with a comma character.
5. We print the colorsString variable to the console.