Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
String.prototype.toCamelCase()
String.prototype.toCamelCase = function(){
return this.split(/\s+/).map(function(word, index){
word = word.toLowerCase();
if(index !== 0){
return word.split('').map(function(char, i){
if(i===0){
return char.toUpperCase();
}
return char;
}).join('')
}
return word;
}).join('');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment