Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
reduce and regexp solution in Clear category for Popular Words by akaka
function popularWords(text: string, words: string[]) {
return words.reduce((p, c) => ({...p, [c]: (text.match(new RegExp('\\b' + c + '\\b', 'gi')) || []).length}), {})
}
May 20, 2020
Comments: