0 votes
in JavaScript by
How do you make first letter of the string in an uppercase in Javascript?

1 Answer

0 votes
by

You can create a function which uses a chain of string methods such as charAt, toUpperCase and slice methods to generate a string with the first letter in uppercase.

function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}
...