Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input){
- let coolThresHold = 1;
- let firstPattern = /(\d)/g;
- let array;
- let count = 0;
- let number = 0;
- let emojiPattern = /(\*{2}|:{2})([A-Z][a-z]{2,})(\1)/g;
- let arr;
- let coolest = [];
- let newArr = '';
- for(let line of input){
- while((array = firstPattern.exec(line)) !== null){
- coolThresHold *= +(array[1]);
- }
- while((arr = emojiPattern.exec(line))!== null){
- count++;
- newArr = arr[2];
- for(let i = 0; i < newArr.length; i++){
- number += newArr[i].charCodeAt(0);
- if(number > coolThresHold){
- coolest.push(arr[0]);
- break;
- }
- }
- number = 0;
- }
- }
- console.log(`Cool threshold: ${coolThresHold}`);
- console.log(`${count} emojis found in the text. The cool ones are:`);
- if(coolest.length > 0){
- console.log(coolest.join('\n'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement