Skip to content

makeOxfordList

Jason Godesky edited this page Jul 11, 2026 · 2 revisions

makeOxfordList takes an array of strings and returns a single string listing each element from the array, using conjunctions and a serial comma.

Parameters

items?: string[]

The items to include in the list. If not provided, returns a null string ('').

conjunction: string = 'and'

The conjunction to use. Exposed as a parameter to make internationalization easier.

Default: 'and'

Returns

A new string with the items listed using a conjunction and a serial comma.

Examples

import { makeOxfordList } from '@revolutionarygamesco/common'

makeOxfordList() // ''
makeOxfordList([]) // ''
makeOxfordList(['vittles']) // 'vittles'
makeOxfordList(['vittles', 'fresh water']) // 'vittles and fresh water'
makeOxfordList(['vittles', 'fresh water', 'rum') // 'vittles, fresh water, and rum'

Clone this wiki locally