Created
September 8, 2017 11:47
-
-
Save kahl-dev/146c920a96addbe0eb590d9f2a38de0b to your computer and use it in GitHub Desktop.
Handle dataset
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 hyphenToCamelCase(string) { | |
return string.replace('data-', '').replace(/-([a-z])/g, string => { | |
return string[1].toUpperCase(); | |
}); | |
} | |
function camelCaseToHyphen(string) { | |
return `data-${string.replace(/([A-Z])/g, string => { | |
return `-${string.toLowerCase()}`; | |
})}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment