Last active
April 7, 2016 05:55
-
-
Save mmloveaa/9a71d88d67a1f59b226903b91f34ae41 to your computer and use it in GitHub Desktop.
4-6- Monkey Patching
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
String.prototype.snakesToCamels = function(){ | |
console.log(this); | |
var someString = this.toLowerCase().split('_'); | |
return someString.reduce(function(a,b,index){ | |
if(index===0){ | |
return a+b | |
} else | |
{ | |
return a+b[0].toUpperCase()+b.slice(1); | |
} | |
},""); | |
} | |
"Will_is_the_greatest".snakesToCamels(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment