You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
529 B

4 years ago
  1. var toString = require('./toString'),
  2. upperFirst = require('./upperFirst');
  3. /**
  4. * Converts the first character of `string` to upper case and the remaining
  5. * to lower case.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 3.0.0
  10. * @category String
  11. * @param {string} [string=''] The string to capitalize.
  12. * @returns {string} Returns the capitalized string.
  13. * @example
  14. *
  15. * _.capitalize('FRED');
  16. * // => 'Fred'
  17. */
  18. function capitalize(string) {
  19. return upperFirst(toString(string).toLowerCase());
  20. }
  21. module.exports = capitalize;