Anjan Dutta

How to capitalize the first letter of any string in Javascript

How to capitalize the first letter of any string in Javascript

To capitalize the first letter in javascript you can use the below javascript code.

The Javascript

function capitalize(text)
{
return text[0].toUpperCase() + text.slice(1);
}
let s = 'hello world';
console.log(capitalize(s));