Skip to content

@technobuddha > library > String > Construction

Function: ensurePrefix()

ts
function ensurePrefix(input: string, prefix: string): string;

Defined in: ensure-prefix.ts:9

Add a prefix to a string, if it does not already have the prefix

Parameters

ParameterTypeDescription
inputstringThe string
prefixstringThe prefix

Returns

string

The prefix followed by the string