📌 📄 内容摘要:
@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...
────────── 链接信息 ────────── 🔗 论坛链接: linux.do 📎 访问地址: https://linux.do/t/topic/197988/1 ─────────────────────────────
📢 来源:LINUX DO