Advertisement
bebo231312312321

Untitled

Mar 25th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function emojiDetector(input) {
  2.         let path =  /(::|\*\*)([A-Z][a-z]{2,})\1/g;
  3.         let digitPath = /(\d)/g
  4.         let digitsSum = input[0].match(digitPath)
  5.             .map(Number)
  6.             .reduce((a, b) => (a * b));
  7.         let emojiSymbol = []
  8.         let foundCounter = 0
  9.         let matches = input.shift()
  10.             .matchAll(path);
  11.         if (matches !== null) {
  12.             for (let word of matches) {
  13.                 console.log(word)
  14.                 let emojiAscii = 0
  15.                 foundCounter++
  16.                 let emoji = word[2]
  17.              let wordMap = [...emoji].filter(x => emojiAscii += x.charCodeAt())
  18.                 emojiAscii < digitsSum ? "" : emojiSymbol.push(word[0]);
  19.             }
  20.         }
  21.     console.log(`Cool threshold: ${digitsSum}`)
  22.     console.log(`${foundCounter} emojis found in the text. The cool ones are:`)
  23.     console.log(`${emojiSymbol.join("\n")}`)
  24.     }
  25. 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**"])
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement