API
@agape/string

toTitleCase Function

Converts a string to title case.

API

function toTitleCase(  input: string): string

toTitleCase

string

Converts a string to title case.

@paraminput:  string
The string to be converted to title case.
@returnsstring

Description

Converts a string to title case.

Capitalizes the first letter of each word, except for small words (like "of", "and", "the") unless they appear at the beginning. Preserves words already containing uppercase letters (e.g., acronyms).

Usage

toTitleCase("the quick brown fox"); // "The Quick Brown Fox"
toTitleCase("a tale of two cities"); // "A Tale of Two Cities"
toTitleCase("in the heart of the sea"); // "In the Heart of the Sea"
toTitleCase("API reference guide"); // "API Reference Guide"
toTitleCase("   war and peace   "); // "War and Peace"