Skip to content

Library: toTitleCase()

Eugene Lazutkin edited this page Jul 11, 2018 · 1 revision

toTitleCase() module is a function, which extracts words from a string (using /\w+/ as a lexer) and capitalizes them.

Usage

In a module-enabled environment (like Babel) it can be accessed like that:

import toTitleCase from '@researchnow/reno/src/utils/toTitleCase';

In global-based environments (like a browser) it is frequently mapped to Reno.utils.toTitleCase.

toTitleCase(str)

The function takes the following arguments:

  • str is a string to be parsed for words and capitalized.

It returns a string where words are capitalized.

Examples

assert(toTitleCase('one - TWO  tHrEe') === 'One - Two  Three');

Clone this wiki locally