Home > OS >  How to Convert first word of a sentence to UPPERCASE LETTERS in javascript/angularjs?
How to Convert first word of a sentence to UPPERCASE LETTERS in javascript/angularjs?

Time:10-05

How to Convert first word of a sentence to UPPERCASE LETTERS in javascript/angularjs ?

CodePudding user response:

let firstUpper = "some text to work".split(' ')[0].toUpperCase();

CodePudding user response:

Basic solution:

function capitalizeFirstLetter(string) {
 return string.charAt(0).toUpperCase()   string.slice(1);
 }

   console.log(capitalizeFirstLetter('foo')); // Foo ´´´
  • Related