From 92c2a229d9c9b510d71b928978872a8b107e9d5a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 11 Apr 2023 09:47:25 +0700 Subject: Documentation and refactor code --- src/core/utils/toTitleCase.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/core/utils/toTitleCase.js') 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() -- cgit v1.2.3