stringzy
Version:
A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.
13 lines (12 loc) • 371 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.capitalize = capitalize;
function capitalize(str) {
if (typeof str !== 'string') {
throw new TypeError('Input must be a string');
}
return str
.split(' ')
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
.join(' ');
}