interface String { toTitleCase(): string; } String.prototype.toTitleCase = (): string => ((!this) || (this.length === 0) || (typeof (this) !== 'string')) ? '' : (this.split(/\s/gi).map(n => ((!!n) && (n.length > 0)) ? (n.charAt(0).toUpperCase() + n.substr(1).toLowerCase()) : '').join(' '));