From b3dcbfab001c9e7bd268b545cf973a739b0207b6 Mon Sep 17 00:00:00 2001 From: rishabhsharma1997 Date: Fri, 9 Aug 2024 20:33:44 +0530 Subject: [PATCH] fix: lettering capitalization in TOC Signed-off-by: rishabhsharma1997 --- src/custom/TOCChapter/TOCChapter.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/custom/TOCChapter/TOCChapter.tsx b/src/custom/TOCChapter/TOCChapter.tsx index 35e78e96..125a7380 100644 --- a/src/custom/TOCChapter/TOCChapter.tsx +++ b/src/custom/TOCChapter/TOCChapter.tsx @@ -9,10 +9,11 @@ interface TOCProps { const TOC: React.FC = ({ availableChapters, currentChapter, onClick }) => { const reformatTOC = (data: string): string => { - let newData = data.split('-').join(' '); - const firstLetter = newData.charAt(0).toUpperCase(); - newData = `${firstLetter}${newData.slice(1)}`; - return newData; + const words = data.split('-'); + const formattedString = words + .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); + return formattedString; }; return (