Created
January 17, 2022 20:24
-
-
Save atomize/9899c19a2d686756b1fae057a93be466 to your computer and use it in GitHub Desktop.
camelCase to Camel Case (Caps 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 camelCase2capsCase = (inputString) => { | |
return inputString.replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); }) | |
} | |
const dateBuiltLabel = camelCase2capsCase('dateBuilt'); | |
console.log(dateBuiltLabel) // 'Date Built' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment