How do I make the first letter of a string uppercase in JavaScript? How do I make the first letter of a string uppercase in JavaScript? javascript javascript

How do I make the first letter of a string uppercase in JavaScript?


The basic solution is:

function capitalizeFirstLetter(string) {  return string.charAt(0).toUpperCase() + string.slice(1);}console.log(capitalizeFirstLetter('foo')); // Foo