/* add string capitalize helper */ Object.defineProperty(String.prototype, 'capitalize', { value: function() { return this.charAt(0).toUpperCase() + this.slice(1); }, enumerable: false });
JavaScript Capitalize Helper Function
To make use of the code above you can now call the "capitalize()" function after defining the string.
"hello world".capitalize() // Hello world
Leave a reply