Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
With reduce solution in Clear category for Popular Words by flytaly
function popularWords(text: string, words: string[]) {
const dictionary = words.reduce((acc, w) => ({ ...acc, [w]: 0 }), {})
return text
.toLowerCase()
.split(/\s/)
.reduce((dic, word) => {
if (words.includes(word)) dic[word] += 1
return dic;
}, dictionary)
}
April 23, 2020
Comments: