<!DOCTYPE html> <html> <head> </head> <body> <button onclick="arrayjoin()">Click to convert array to string by join</button> <p id="p1"></p> <script type="text/javascript"> function arrayjoin(){ var USStates = ["New York", "Texas", "Florida","Alaska"]; Strarr = USStates.join(" | "); document.getElementById("p1").innerHTML = Strarr; } </script> </body> </html>