From ce8751dabeef4e208a5cbf4660567c62292d5634 Mon Sep 17 00:00:00 2001 From: Max <133934232+Kleostro@users.noreply.github.com> Date: Thu, 9 May 2024 03:24:20 +0300 Subject: [PATCH] feat: add formatted text function --- src/shared/utils/formattedText.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/shared/utils/formattedText.ts diff --git a/src/shared/utils/formattedText.ts b/src/shared/utils/formattedText.ts new file mode 100644 index 00000000..651faaed --- /dev/null +++ b/src/shared/utils/formattedText.ts @@ -0,0 +1,8 @@ +const formattedText = (text: string): string => + text + .trim() + .split(' ') + .map((word) => (word[0] ? word[0].toUpperCase() + word.slice(1).toLowerCase() : '')) + .join(' '); + +export default formattedText;