Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function emojiDetector([input]) {
- let regex = /(\*\*|::)([A-Z][a-z]{2,})\1/g;
- // или /(::|\*\*)[A-Z]{1}[a-z]{2,}\1/g;
- if (/[0-9]+/g.test(input)) {
- let coolThreshold = input.match(/[0-9]/g);
- coolN = 1;
- for (let num of coolThreshold){
- num = Number(num);
- coolN *= num;
- }
- // let coolThreshold = input.match(/[0-9]+/g);.join('').split('').reduce((a, b) => {return a *= b; }, 1) || 0;
- console.log(`Cool threshold: ${coolN}`);
- // console.log(`Cool threshold:${coolThreshold}`);
- let matches = input.match(regex);
- console.log(`${matches.length} emojis found in the text. The cool ones are:`);
- matches.forEach(x => {
- let current = x.substring(2, x.length - 2);
- let currentSum = current.split('').reduce((a, b) => a += b.charCodeAt(), 0);
- if (currentSum > coolN) {
- console.log(x);
- }
- })
- }
- }
- 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