Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Popular Words solution in Uncategorized category for Popular Words by vvm70
"use strict";
function popularWords(text: string, words: string[]) {
let pw = {};
for(let w of words)
pw[w] = text.split(/\s/g).filter(x => x.match(RegExp('^' + w + '$', 'gi'))).length;
return pw;
}
console.log('Example:')
console.log(popularWords(`
When I was One
I had just begun
When I was Two
I was nearly new`, ['i', 'was', 'three', 'near']))
June 28, 2020