Capitalize strings in JavaScript.
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
var myString = 'abc';
console.log(myString.capitalize()); // output is 'Abc'
Written by tmaster
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#String
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#