Created
October 14, 2018 13:34
-
-
Save chrishutchinson/f3486e9637bf6cb59d02c3afadd699ca to your computer and use it in GitHub Desktop.
Hacking with JavaScript and Shortcuts (#3)
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
const emojis = { | |
american: "🇺🇸", | |
science: "🔬", | |
horror: "🙀", | |
second: "🥈", | |
written: "✏️", | |
television: "📺" | |
}; | |
const replaceWordsWithEmoji = text => | |
Object.keys(emojis).reduce( | |
(acc, word) => acc.replace(new RegExp(word, "g"), emojis[word]), | |
text | |
); | |
document.body.innerHTML = replaceWordsWithEmoji(document.body.innerHTML); | |
completion(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment