Created
May 16, 2021 20:33
-
-
Save macro6461/209feb67122283ac471da2d33c0b15fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const genWordList = (text) => { | |
var str = '' | |
var wordMap = {} | |
text.replace(/[^A-Za-z0–9\/]+/g, "").split(" ").forEach(word=>{ | |
var keyToCheck = word.toLowerCase() | |
if (wordMap[keyToCheck]){ | |
wordMap[keyToCheck] += 1 | |
} else { | |
wordMap[keyToCheck] = 1 | |
} | |
}) | |
for (var k in wordMap){ | |
console.log(`${k}: ${wordMap[k]} times`) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment