0

Hi i have a variable like below,

const str = 'passed'

now i want to capitalize only the first letter of the string. i can do it like below

const str2 = str.charAt(0).toUpperCase() + str.slice(1);

but is there any other better way to do the same using javascript?

could someone help me with this. thanks.

stackuser
  • 257
  • 1
  • 5
  • 14
  • 1
    Lots of different approaches in that mentioned duplicate - which you could have easily found yourself btw., by just typing your chosen question title into Google verbatim. – CBroe Nov 02 '21 at 11:16
  • https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform – Mister Jojo Nov 02 '21 at 11:17

0 Answers0