Join elements of an array without an ending comma

Let's assume that you have the following array:

javascript
let random = ['Jeff', 'Bill', 'Elon', 'Erik']

If you want to join the elements without adding a comma at the string's end:

javascript
let join = random.join()
// 'Jeff,Bill,Elon,Erik'

This could be useful if you wanted to create a linear-gradient in React from an array.

Example:

jsx
const Gradient = () => {

    const colors = ['#0f2027', '#203a43', '#2c5364']

    return (
        <div className = 'Gradient' style = {{background: `linear-gradient(to right, ${colors.join()})`}}>
            I'm an element with gradient background
        </div>
    )

}

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.