Created
February 2, 2016 09:50
-
-
Save dineshsprabu/7abd2f76fb39797e70c4 to your computer and use it in GitHub Desktop.
Changing First Letter of a String to Upper Case in Javascript
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
/* Changing first letter of string to uppercase */ | |
String.prototype.toFirstUpperCase = function(){ | |
return this.slice(0,1).toUpperCase()+this.slice(1); | |
} | |
/* Usage */ | |
"example".toFirstUpperCase(); //Example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+this.slice(1).toLowerCase();
:)