mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 22:53:37 +08:00
14 lines
283 B
JavaScript
14 lines
283 B
JavaScript
|
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;
|
||
|
};
|