@feahter网页词汇统计脚本【js版】 中发帖

const extractMostFrequentWord=(text)=>{
const words = text.split(/\s+/);
const wordCounts = {};
let mostFrequentWord = '';
let maxCount = 0;
for (const word of words) {
if (wordCounts[word]) {
wordCounts[word]++;
} else {
wordCounts[word] = 1;
}

if (wordCounts[word] > maxCount) {
maxCount = wordCounts[word];
mostFrequentWord = word;
}
}
r...