refact: favour functional approach

This commit is contained in:
Jean-Philippe Sirois
2019-08-19 00:14:29 -04:00
parent e53ed690df
commit 357e2dd2d2
+4 -6
View File
@@ -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 }) {