to capital case javascript

JavaScript
var str = "Hello World!";
var res = str.toUpperCase();  //HELLO WORLD!const toCapitalCase = (string) => {
    return string.charAt(0).toUpperCase() + string.slice(1);
};function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}

console.log(capitalizeFirstLetter('foo')); // Fooconst name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)
function capitalizeName(name) {
  return name.replace(/\b(\w)/g, s => s.toUpperCase());
}


Source

Also in JavaScript: