diff --git a/framework/core/js/lib/helpers/punctuate.js b/framework/core/js/lib/helpers/punctuate.js new file mode 100644 index 000000000..a208093e6 --- /dev/null +++ b/framework/core/js/lib/helpers/punctuate.js @@ -0,0 +1,13 @@ +export default function punctuate(items) { + var newItems = []; + + items.forEach((item, i) => { + newItems.push(item); + + if (i <= items.length - 2) { + newItems.push((items.length > 2 ? ', ' : '')+(i === items.length - 2 ? ' and ' : '')); + } + }); + + return newItems; +};