Capitalizes the first letter of every word, keeping spaces and separators
intact (distinct from pascalCase, which removes them).
Uses simple every-word capitalization rather than the "small words stay
lowercase" (a, an, the, of, ...) style convention some style guides use —
simpler, more predictable, and easier to test, at the cost of not being
"typographically correct" by those style guides' rules.
Parameters
text: string
A string to convert to Title Case.
Returns string
The string with the first letter of every word capitalized.
Example
titleCase('the lord of the rings'); // 'The Lord Of The Rings' titleCase('hello-world_example'); // 'Hello-World_Example'
Capitalizes the first letter of every word, keeping spaces and separators intact (distinct from pascalCase, which removes them).
Uses simple every-word capitalization rather than the "small words stay lowercase" (a, an, the, of, ...) style convention some style guides use — simpler, more predictable, and easier to test, at the cost of not being "typographically correct" by those style guides' rules.