From e6b9b3f9e0eb48796b29d22ef28dfa9b5fa2ee38 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sat, 2 Aug 2025 16:19:43 +0200 Subject: [PATCH] Add capitalize --- lib/format.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/format.ts diff --git a/lib/format.ts b/lib/format.ts new file mode 100644 index 00000000..67b0e882 --- /dev/null +++ b/lib/format.ts @@ -0,0 +1,12 @@ +function capitalizeOne(str: string) { + if (!str) return ""; + return str[0].toUpperCase() + str.slice(1).toLowerCase(); +} + + +export function capitalize(str: string) { + return str + .split(" ") + .map(word => capitalizeOne(word)) + .join(" "); +} \ No newline at end of file