Skip to content
Nate
Stephens

Capitalize First Letter

JavaScript

const capitalizeFirstLetter = ([firstLetter, ...restOfWord]) =>
  firstLetter.toUpperCase() + restOfWord.join('');

TypeScript

const capitalizeFirstLetter = <T extends string>([
  firstLetter,
  ...restOfWord
]: T) => {
  return (firstLetter.toUpperCase() + restOfWord.join('')) as Capitalize<T>;
};

Last Updated: