diff options
Diffstat (limited to 'src/core/utils/toTitleCase.js')
| -rw-r--r-- | src/core/utils/toTitleCase.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/utils/toTitleCase.js b/src/core/utils/toTitleCase.js index 4335824d..dab1dc33 100644 --- a/src/core/utils/toTitleCase.js +++ b/src/core/utils/toTitleCase.js @@ -1,3 +1,12 @@ +/** + * Converts a string to title case. + * Title case capitalizes the first character of each word in the string, + * and sets the remaining characters to lowercase. + * + * @param {string} str - The input string to be converted to title case. + * @returns {string} - The string in title case. + */ + const toTitleCase = (str) => { return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() |
