Skip to content

Instantly share code, notes, and snippets.

Created June 10, 2023 20:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save r4881t/1f1af03b70ef7604be4d5501658cf236 to your computer and use it in GitHub Desktop.
Get category & sub category names to show in UI
function getPresentableCatText(slug: string): string {
const words = slug.split('-');
const capitalizedWords = => word.charAt(0).toUpperCase() + word.slice(1));
return capitalizedWords.join(' ');
const slugifiedString = 'arts-and-entertainment';
const unslugifiedString = getPresentableCatText(slugifiedString);
Arts And Entertainment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment