@technobuddha > library > String > Operations
Function: initials()
ts
function initials(words: string): string;Defined in: initials.ts:16
Returns the uppercase initials of the given string.
Extracts the first letter of each word in the input string and concatenates them into a single uppercase string.
Parameters
| Parameter | Type | Description |
|---|---|---|
words | string | The input string from which to extract initials. |
Returns
string
The uppercase initials of the input string.
Example
typescript
initials("John Doe") // "JD"
initials("alice in wonderland") // "AIW"