Skip to content
Related Articles
Open in App
Not now

Related Articles

How to create a string by joining the elements of an array in JavaScript ?

Improve Article
Save Article
  • Last Updated : 09 Dec, 2022
Improve Article
Save Article

Given an array containing array elements and here we will join all the array elements to make a single string. To join the array elements we use arr.join() method. This method is used to join the elements of an array into a string. The elements of the string will be separated by a specified separator and its default value is a comma(,).



Example: In this case, we use an empty separator i.e. array.join(“”) to join the array elements.


<body style="text-align: center;">
    <h1 style="color:green;">
        How to create a string by joining the<br>
        elements of an array in JavaScript?
    <h4>Original Array: ["Welcome", "Geeks", "for", "Geeks"]</h4>
    <button onclick="geeks()">Click Here!</button>
    <h4 id="result"></h4>
        function geeks() {
            var str = ["Welcome", "Geeks", "for", "Geeks"];
                = "Joined String: " + str.join("");



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!