Advertisement
bebo231312312321

Untitled

Mar 24th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    function emojiDetector(input) {
  2.  
  3.         let path =  /(::|\*\*)([A-Z][a-z]{2,})\1/g;
  4.         let digitPath = /(\d)/g
  5.         let digitsSum = input[0].match(digitPath)
  6.             .map(Number)
  7.             .reduce((a, b) => (a * b));
  8.         let emojiSymbol = []
  9.         let foundCounter = 0
  10.         let matches = input.shift()
  11.             .matchAll(path);
  12.         if (matches !== null) {
  13.             for (let word of matches) {
  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.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement