Nodejs String Title Case title()

Here you can find the source of title()

Method Source Code

String.prototype.title = function() {
    return this.replace(/\w\S*/g, function(txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });/*ww w  . j a  v  a 2  s .  c om*/
};

Related

  1. cleanTitle()
    String.prototype.cleanTitle = function() {
      var title = this.trim().replaceHtmlEntites();
      title = encodeURI(title);
      return title.replace(/&/g, '%26').replace(/#/g, '%23');
    };
    
  2. title()
    String.prototype.title = function() {
      return this.charAt(0).toUpperCase() + this.slice(1);
    };
    module.exports = String;
    
  3. titleCase()
    String.prototype.titleCase = function () {  
      return this.replace(/\w\S*/g, (txt) => {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
      });
    };
    
  4. titleCase()
    String.prototype.titleCase= function()
        return this.charAt(0).toUpperCase() + this.substr(1);
    
  5. titleCase(str)
    function titleCase(str) {
      var arr = str.split(" ");
      var combineArr = [];
      var resultArr = [];
      for(var i = 0; i<arr.length; i++){
        var upperArr = [];
        var lowerArr = [];  
        for(var j = 0; j < arr[i].length; j++){      
          if(j === 0){
    ...