Source

string/capitalizeWords.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Reference: https://www.w3resource.com/javascript-exercises/javascript-basic-exercise-50.php
 *
 * @param {string} str
 * @returns {string}
 * @category string
 * @module capitalizeWords
 */
var capitalizeWords = function (str) {
    var words = str.split(' ').filter(function (s) { return s; });
    var capitalizedWords = words.map(function (word) { return "".concat((word[0] || '').toUpperCase()).concat(word.substring(1)); });
    return capitalizedWords.join(' ');
};
exports.default = capitalizeWords;