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
Try this,
var arr = ['tag1', 'tag2', 'tag3']; var lastStr = arr.pop(); var str = "Content tagged " + arr.join(", ") + " and " + lastStr;