Skip to content

Instantly share code, notes, and snippets.

@adam-lynch
Last active December 17, 2015 12:29
Show Gist options
  • Save adam-lynch/5609705 to your computer and use it in GitHub Desktop.
Save adam-lynch/5609705 to your computer and use it in GitHub Desktop.
Converts hypenated strings to camelCase. E.g. "hello-world" -> "helloWorld", "this-is-a-gist" -> "thisIsAGist", etc
/**
* @param str string
*
* @return string
*
* @author adam-lynch
*/
var convertHyphenatedToCamelCase = function( str ){
return str.replace( /-([a-z])/g, function( matches ){
return matches[1].toUpperCase();
} );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment