Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function emojiDetector(input) {
- let path = /(::|\*\*)([A-Z][a-z]{2,})\1/g;
- let digitPath = /(\d)/g
- let digitsSum = input[0].match(digitPath)
- .map(Number)
- .reduce((a, b) => (a * b));
- let emojiSymbol = []
- let foundCounter = 0
- let matches = input.shift()
- .matchAll(path);
- if (matches !== null) {
- for (let word of matches) {
- console.log(word)
- let emojiAscii = 0
- foundCounter++
- let emoji = word[2]
- let wordMap = [...emoji].filter(x => emojiAscii += x.charCodeAt())
- emojiAscii < digitsSum ? "" : emojiSymbol.push(word[0]);
- }
- }
- console.log(`Cool threshold: ${digitsSum}`)
- console.log(`${foundCounter} emojis found in the text. The cool ones are:`)
- console.log(`${emojiSymbol.join("\n")}`)
- }
- emojiDetector(["In the Sofia Zoo there are 311 animals in total! ::Smiley:: This includes 3 **Tigers**, 1 ::Elephant:, 12 **Monk3ys**, a **Gorilla::, 5 ::fox:es: and 21 different types of :Snak::Es::. ::Mooning:: **Shy**"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement