Capitalise a word

Easy
52
2
84.5% Acceptance

Implement a function called capitalizeWord(word) that capitalizes the first letter of the input string word and returns the capitalized string.

Instructions

  • The function should return a new string with the first letter capitalized.
  • If the input is an empty string, return an empty string.
  • The input will always be a string consisting of one word, and will not contain numbers or special characters.
  • Transform only the first character, leaving the rest unchanged.

Example test cases

capitaliseWord('hello'); // Output: 'Hello' capitaliseWord('mom'); // Output: 'Mom' capitaliseWord('dAD'); // Output: 'DAD'

Hints

  • Use the toUpperCase method.