Skip to content

capitalize() function

Converts the first character of str to upper case and the remaining characters to lower case.

Signature:

typescript
declare function capitalize(str: string): string;

Example

ts
capitalize("fred"); // "Fred"
capitalize("FRED"); // "Fred"
capitalize(""); // ""

Open Source Code

Released under the Apache-2.0 License.