1

Title-case a string

Function JavaScript 1 revisions 47 6 months ago 6 months ago
function toTitleCase(str) {
    return str.replace(/\w\S*/g, (txt) => {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });
}