Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Necesito crear un método que ponga en mayúsculas solo el primer carácter de una cadena (Javascript)

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 Onimusha

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Segú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

about 4 years ago · Santiago Trujillo Report

0

 String.prototype.tittle = function() { return this.charAt(0).toUpperCase() + this.substring(1) } console.log('onimusha'.tittle())

about 4 years ago · Santiago Trujillo Report

0

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
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!