Created
June 10, 2023 20:22
-
-
Save r4881t/1f1af03b70ef7604be4d5501658cf236 to your computer and use it in GitHub Desktop.
Get category & sub category names to show in UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPresentableCatText(slug: string): string { | |
const words = slug.split('-'); | |
const capitalizedWords = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)); | |
return capitalizedWords.join(' '); | |
} | |
/* | |
const slugifiedString = 'arts-and-entertainment'; | |
const unslugifiedString = getPresentableCatText(slugifiedString); | |
console.log(unslugifiedString); | |
Arts And Entertainment | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment