To take a JS array like [“item1”, “item2”, “item3″….] into a nice human readable string of “item1, item2 & item3” with all the first items getting comma separated and the final one with an ampersand use:
resultString = array.length > 1 ? array.slice(0,-1).join(', ') + ' & ' + array[array.length -1] : array[0]

Leave a Reply