Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Join All Elements of an Array into a String</title> </head> <body> <script> let colors = ["Red", "Green", "Blue"]; document.write(colors.join() + "<br>"); // Prints: Red,Green,Blue document.write(colors.join("") + "<br>"); // Prints: RedGreenBlue document.write(colors.join("-") + "<br>"); // Prints: Red-Green-Blue document.write(colors.join(", ")); // Prints: Red, Green, Blue </script> </body> </html>