Skip to content

@technobuddha > library > Array > Operations

Function: conjoin()

ts
function conjoin<T>(input: ArrayLike<T>, options: ConjoinOptions): string;

Defined in: conjoin.ts:46

Create a list from an array, separating values and inserting a conjunction

Type Parameters

Type ParameterDefault type
Tunknown

Parameters

ParameterTypeDescription
inputArrayLike<T>Array of values
optionsConjoinOptionssee ConjoinOptions

Returns

string

Example

typescript
const stooges = ['Larry', 'Moe', 'Curly'];
conjoin(stooges);
// 'Larry, Moe, and Curly'
typescript
const amigos = ['Lucky Day', 'Dusty Bottoms', 'Ned Nederlander'];
conjoin(amigos, { conjunction: 'or', oxford: false, separator: ';' });
// 'Lucky Day; Dusty Bottoms or Ned Nederlander'