<!DOCTYPE html>
<html>
<body>

<p>Click the button to join the array elements into a string.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var fruits = ["Banana", "Orange", "Apple", "Mango"];
    var x = document.getElementById("demo");
    x.innerHTML = fruits.join(" and ");
}
</script>

</body>
</html>