Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let sum = 0;
- let text = input.shift();
- let pattern = /[,.!? ]:([a-z]){4,}:[,.!? ]/g;
- let foundEmojis = text.match(pattern);
- let pesho=[];
- let emoji = input.shift()
- .split(':')
- .forEach((el)=>{
- el=String.fromCharCode(el);
- pesho.push(el);
- })
- pesho=pesho.join('');
- let emo=[];
- if (foundEmojis) {
- for (let i = 0; i < foundEmojis.length; i++) {
- let all = foundEmojis[i].split(':');
- all=all[1];
- for (let result of all) {
- let chars = result.charCodeAt(0);
- sum += chars;
- }
- all=`:${all}:`
- emo.push(all);
- }
- }
- if (sum > 0) {
- emo.forEach((element)=>{
- element=element.split(':');
- let currentEmoji=element[1];
- if(currentEmoji=== pesho){
- sum*=2;
- }
- })
- console.log(`Emojis found: ${emo.join(', ')}`);
- }
- console.log(`Total Emoji Power: ${sum}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement