This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countWordsInText(text) { | |
let count = {}; | |
let popularity = []; // maybe this should be an object due to JS array expansion logic | |
function updateWord(word, ct) { | |
if (popularity[ct-1]) { | |
popularity[ct-1].delete(word); | |
} | |
if (!popularity[ct]) { | |
popularity[ct] = new Set(); |