/**
* Change string from snake case to camelCase
*
* @param {string} str Input snake case string
* @return {string} Output camel case string
*/
function toCamelCase(str) {
str = str.replace(/[-_\s]+(.)?/g, (match, ch) => // eslint-disable-line no-param-reassign
(ch ? ch.toUpperCase() : ''),
);
// Ensure first chat is always lowercase
return str.substr(0, 1).toLowerCase() + str.substr(1);
};
Last active
July 24, 2020 21:38
-
-
Save assembledadam/80c97eb03fdc35e1e92ae38537a02ac0 to your computer and use it in GitHub Desktop.
Function to convert snake case to camelCase (ES6+)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment