Use .split() to convert string to array, .join() to convert array to string
const text = 'hello-world-javascript';
const words = text.split('-');
console.log(words); // ['hello', 'world', 'javascript']
const rejoined = words.join(' ');
console.log(rejoined); // "hello world javascript"const csv = 'John,Doe,30,Engineer';
const fields = csv.split(',');
console.log(fields);
// Transform and rejoin
const formatted = fields.map(f => f.trim()).join(' | ');
console.log(formatted);const text = 'a,b;c:d';
const parts = text.split(/[,;:]/);
// ['a', 'b', 'c', 'd']const text = 'a-b-c-d';
const parts = text.split('-', 2);
// ['a', 'b']Avoid manual string parsing with loops
// DON'T DO THIS
var result = '';
for (var i = 0; i < arr.length; i++) {
result += arr[i];
if (i < arr.length - 1) result += ',';
}✓ Works in all modern browsers (ES3+)