Capitalise First Letter using JavaScript

   JavaScript

How to capitalise only the first letter of any word?

Solution

function firstLetterUppercase(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
};

console.log(firstLetterUppercase('hello')); // Hello
Tags: CapitalizeCapitalize First LetterJavaScript

Leave a Comment