Brian Yang
Brian Yang
algorithm designer
Mar 24, 2020 1 min read

Capitalization

Given a phrase, capitalize every word.

Solution

const capitalize = phrase => {
    const words = [];

    for (let word of phrase.split(" "))
        words.push(word[0].toUpperCase() + word.slice(1));

    return words.join(" ");
};
comments powered by Disqus