How to lowercase a string and then capitalize only the first letter in JavaScript

1 Answer

0 votes
let str = 'javascripT C++ C PHP';

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

console.log(str);

  
  
  
  
/*
run:

"Javascript c++ c php"
  
*/

 



answered May 15, 2022 by avibootz
...