You can also implement a pure javascript extension method like this:
String.prototype.capitalize = function () {
return this.toLowerCase().replace(/\b[a-z]/g, function (letter) {
return letter.toUpperCase();
});
};
And call it like this:
"HELLO world".capitalize()