Created
August 9, 2023 21:49
-
-
Save lacymorrow/b60fbbde039f502a2577460ba171d52b to your computer and use it in GitHub Desktop.
JS function to format a camelCase string into a "Camel Case" pretty string
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
function prettyFormat(str) { | |
return str.split(/(?=[A-Z])/) | |
.map(function(word) { | |
return word.charAt(0).toUpperCase() + word.slice(1); | |
}) | |
.join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage