Array.join([seperator]) Last updated: 22. Jul 2024
Joins all elemnts in an array into a string
Parameters
Name | Type | Description |
---|---|---|
seperator (optional) | string | Default seperator is comma (,). |
Returns
A string combining all array items into this one string.
Example
Data
{
"items" : ["Red", "Green", "Blue"]
}
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.<p>
// Expected result: "Red,Green,Blue"
#items.join()#
</p>
<p>
// Expected result: "RedGreenBlue"
#items.join('')#
</p>
<p>
// Expected result: "Red-Green-Blue"
#items.join('-')#
</p>
Output
The #JS code above produces the output shown below:<p>
// Expected result: "Red,Green,Blue"
Red,Green,Blue
</p>
<p>
// Expected result: "RedGreenBlue"
RedGreenBlue
</p>
<p>
// Expected result: "Red-Green-Blue"
Red-Green-Blue
</p>