Having a list (array) of tags [\'tag1\', \'tag2\', \'tag3\'] I want to generate a nice title like: Content tagged tag1, tag2 and tag3.
[\'tag1\', \'tag2\', \'tag3\']
Content tagged tag1, tag2 and tag3
For the
Something like this would be my approach
function arrayFormat(arr) { var output = arr.splice(0, arr.length - 1).join(", "); output += " and " + arr[0]; return output; } console.log(arrayFormat(["a", "b", "c"]));