Mi método incorrecto:
String.prototype.tittle = function(){ return (this.split('')[0].toUpperCase()) + ((Array(this)).shift()) } console.log('onimusha'.tittle()) // it returns Oonimusha, was expected OnimushaSegún su resultado esperado, desea esto.
String.prototype.tittle = function(){ return this[0].toUpperCase() + this.slice(1) } console.log('onimusha'.tittle()) // it returns Oonimusha, was expected Onimusha String.prototype.tittle = function() { return this.charAt(0).toUpperCase() + this.substring(1) } console.log('onimusha'.tittle())probar:
String.prototype.tittle = function() { // break up string into individual characters let chars = this.split(''); // uppercase the first character and save it back to the first element chars[0] = chars[0].toUpperCase(); // then piece back the string and return it return chars.join(''); } console.log('hello'.tittle()); // Hello