From f99e0aba70efad0deb907d8e27f09fc9f527c8a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Feb 2023 17:07:50 +0700 Subject: Refactor --- src2/core/utils/toTitleCase.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src2/core/utils/toTitleCase.js (limited to 'src2/core/utils/toTitleCase.js') diff --git a/src2/core/utils/toTitleCase.js b/src2/core/utils/toTitleCase.js new file mode 100644 index 00000000..5cfd70d0 --- /dev/null +++ b/src2/core/utils/toTitleCase.js @@ -0,0 +1,8 @@ +export default function toTitleCase(str) { + return str.replace( + /\w\S*/g, + function(txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + } + ); +} \ No newline at end of file -- cgit v1.2.3