I have searched over the web can can\'t find anything to help me. I want to make the first letter of each word upper case within a variable.
So far i have tried:
Without JQuery
String.prototype.ucwords = function() { str = this.trim(); return str.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, function(s){ return s.toUpperCase(); }); }; console.log('hello world'.ucwords()); // Display Hello World