isFirstLetterCapitalized.js 394 B

12345678910111213141516
  1. 'use strict';
  2. /**
  3. * Check if the first letter of a string is capitalized.
  4. * @param {String} word String to check
  5. * @returns {Boolean} True if first letter is capitalized.
  6. */
  7. function isFirstLetterCapitalized(word) {
  8. if (!word) {
  9. return false;
  10. }
  11. const firstLetter = word.charAt(0);
  12. return firstLetter.toUpperCase() === firstLetter;
  13. }
  14. module.exports = isFirstLetterCapitalized;