string-utils.js 459 B

12345678910111213141516171819202122
  1. /**
  2. * @fileoverview Utilities to operate on strings.
  3. * @author Stephen Wade
  4. */
  5. "use strict";
  6. /**
  7. * Converts the first letter of a string to uppercase.
  8. * @param {string} string The string to operate on
  9. * @returns {string} The converted string
  10. */
  11. function upperCaseFirst(string) {
  12. if (string.length <= 1) {
  13. return string.toUpperCase();
  14. }
  15. return string[0].toUpperCase() + string.slice(1);
  16. }
  17. module.exports = {
  18. upperCaseFirst
  19. };