Lowercases then capitalizes the first letter of every word
export const capitalize = (str: string): string => { return str.toLowerCase().replace(/(?:^|\s|-)\S/g, (match) => match.toUpperCase());}; Copy
export const capitalize = (str: string): string => { return str.toLowerCase().replace(/(?:^|\s|-)\S/g, (match) => match.toUpperCase());};
A new string with every word capitalized
Lowercases then capitalizes the first letter of every word
Source