Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (input = []) {
- let text = input.shift();
- let patternNumbers = /[0-9]/g;
- let patternEmojis = /([:*]{2})([A-Za-z]{3,})\1/g;
- let nums = text.match(patternNumbers);
- let emojis = text.match(patternEmojis);
- let coolThreshold = 1;
- for (let num of nums) {
- num = Number(num);
- coolThreshold *= num;
- }
- let coolEmojis = [];
- for (let line of emojis) {
- let currLine = line;
- if (line.includes('**')) {
- let start = '\\**';
- let regex = new RegExp(start, 'g')
- line = line.replace(regex, "")
- } else if (line.includes('::')) {
- let end = '\\::';
- let reg = new RegExp(end, 'g');
- line = line.replace(reg, '')
- }
- let currAscii = 0;
- for (let char of line) {
- let value = char.charCodeAt(0);
- currAscii += value;
- }
- if (currAscii > coolThreshold) {
- coolEmojis.push(currLine);
- }
- }
- console.log(`Cool threshold: ${coolThreshold}`);
- console.log(`${emojis.length} emojis found in the text. The cool ones are:`);
- console.log(`${coolEmojis.join('\n')}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement