Created
June 30, 2020 12:49
-
-
Save srph/e7b84668047f57bbc87e2bfe1b6ecec7 to your computer and use it in GitHub Desktop.
JS: snake_case and pascalCase to "Title Case"
This file contains hidden or 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
const toTanginaMoCase = (str: string): string => { | |
// Convert snake case to title case | |
return str.split('_') | |
.map(str => str.charAt(0).toUpperCase() + str.substr(1)) | |
.join('') | |
.replace(/([A-Z])/g, ' $1') | |
.trim() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment