Join all array elements into string/ JS

PHOTO EMBED

Thu Dec 03 2020 04:20:42 GMT+0000 (Coordinated Universal Time)

Saved by @Amna #javascript

<!DOCTYPE html>
<html>
<body>
​
<h2>JavaScript Array Methods</h2> 
​
<h2>join()</h2>
​
<p>The join() method joins array elements into a string.</p>
​
<p>It this example we have used " * " as a separator between the elements:</p>
​
<p id="demo"></p>
​
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits.join(" * ");
</script>
​
</body>
</html>
​
content_copyCOPY

The join() method also joins all array elements into a string.

https://www.w3schools.com/js/tryit.asp?filename