1

Title-case a string

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