Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
Forked from johnsmith17th/camelCase.js
Created November 15, 2017 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paxperscientiam/ea7a6d5b58e1c429b10205fae18d7f45 to your computer and use it in GitHub Desktop.
Save paxperscientiam/ea7a6d5b58e1c429b10205fae18d7f45 to your computer and use it in GitHub Desktop.
To convert string to camel case in javascript.
function toCamelCase(str) {
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment