UNPKG

codetrix

Version:

A lightweight lodash-style utility library

15 lines (14 loc) 301 B
/** * Capitalizes the first letter of a string. * * @param str - The string to capitalize. * @returns The capitalized string. * * @example * capitalize('hello'); // 'Hello' */ export function capitalize(str) { if (!str) return ''; return str[0].toUpperCase() + str.slice(1); }