Created
October 30, 2019 17:37
-
-
Save rkammer/7c08e7b1f1bcd0fdf5e10fd4a5efb434 to your computer and use it in GitHub Desktop.
camelCase / PascalCase
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 ToCamelCase(attribute) { | |
return attribute.toLowerCase().trim().split('_').reduce((pre, cur) => { | |
return pre + cur.charAt(0).toUpperCase() + cur.slice(1); | |
}); | |
} | |
function ToPascalCase(attribute) { | |
return attribute.toLowerCase().trim().split('_').reduce((pre, cur) => { | |
return pre.charAt(0).toUpperCase() + pre.slice(1) + cur.charAt(0).toUpperCase() + cur.slice(1); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment