From 357e2dd2d2eb72059fa4de632e5021553c000310 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Sun, 18 Aug 2019 23:32:08 -0400 Subject: [PATCH] refact: favour functional approach --- src/components/ResourceBreadcrumb/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/ResourceBreadcrumb/index.tsx b/src/components/ResourceBreadcrumb/index.tsx index 7dfa94a..d9d3b0b 100644 --- a/src/components/ResourceBreadcrumb/index.tsx +++ b/src/components/ResourceBreadcrumb/index.tsx @@ -10,12 +10,10 @@ interface IResourceBreadcrumbProps { } function capitalize(str: string): string { - const split = str.split(" ") - const reconstruct = [] - for (const substr of split) { - reconstruct.push(`${substr.charAt(0).toUpperCase()}${substr.substring(1)}`) - } - return reconstruct.join(" ") + return str + .split(" ") + .map(word => `${word.charAt(0).toUpperCase()}${word.substring(1)}`) + .join(" ") } function Link({ item }: { item: IFileOrFolder }) {