Skip to content

Instantly share code, notes, and snippets.

@rkammer
Created October 30, 2019 17:37
Show Gist options
  • Save rkammer/7c08e7b1f1bcd0fdf5e10fd4a5efb434 to your computer and use it in GitHub Desktop.
Save rkammer/7c08e7b1f1bcd0fdf5e10fd4a5efb434 to your computer and use it in GitHub Desktop.
camelCase / PascalCase
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