How to make first letter capital in a given word in JavaScript?


I want to make the first letter of a given word capitalize, How can I do this in JavaScript?

1 Answer

5 years ago by

Following code shows you how to make the first letter capital letter from a word.

var input = "hello";

var output = input[0].toUpperCase() + input.splice(1);

console.log(output); //=> Hello

You can check this in action here https://onecompiler.com/javascript/3v29u8ysw

5 years ago by Karthik Divi