Here you can find the source of toTitleCase()
//---------STRING UTILS------------ String.prototype.toTitleCase = function(){ return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); }
String.prototype.titleize = function() { var words = this.replace(/_/g, " ").split(' ') var array = [] for (var i=0; i<words.length; ++i) { array.push(words[i].charAt(0).toUpperCase() + words[i].toLowerCase().slice(1)) return array.join(' ')
String.prototype.titleize = function () { var str = this.underscore().humanize(); str = str.replace(/\s\b[\w]/g, function (chr) { return chr.toUpperCase(); }); return str; };
String.prototype.titleize = function(splitter) { var words = this.split(splitter ? splitter : ' ') var array = [] for (var i=0; i<words.length; ++i) { array.push(words[i].charAt(0).toUpperCase() + words[i].toLowerCase().slice(1)) return array.join(' ')
String.prototype.toTitleCase = function() { return this.replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); }; export default String.prototype.toTitleCase;
String.prototype.toTitleCase = function( selector ) { var splitArray; var finalString = ""; if ( typeof ( selector ) === 'undefined' ) { selector = " "; splitArray = this.split ( " " ) ; } else { splitArray = this.split ( selector ) ; splitArray.forEach( function( element ) { finalString += element[0].toUpperCase() + element.substr(1) + selector; } ); finalString = finalString.substr( 0, finalString.length-1); return finalString;
String.prototype.toTitleCase = function () { return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); };
String.prototype.toTitleCase = function () { var str = this; var newStr = ''; var words = str.split(' '); for (var i = 0; i < words.length; i++) { newStr += ' ' + words[i].slice(0, 1).toUpperCase() + words[i].slice(1).toLowerCase(); return newStr.trim(); }; ...
String.prototype.toTitleCase = function() { var str = this; return str.toLowerCase().split(' ').map(function(word) { return (word.charAt(0).toUpperCase() + word.slice(1)); }).join(' ');
'use strict'; var _ = require('underscore'); String.prototype.toTitleCase = function() { var exceptions = ['a', 'an', 'the', 'at', 'by', 'for', 'in', 'of', 'on', 'to', 'up', 'and', 'as', 'but', 'or', 'nor']; return _.map(this.split(' '), function(word) { return _.find(exceptions, function(compare) { return compare === word.toLowerCase(); }) ? word : word.charAt(0).toUpperCase() + word.slice(1); }).join(' '); ...