Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let pattern = /([\:\:|\*\*]{2})([A-Z][a-z]{2,})\1/g;
- let threshold = /\d/g;
- let emojis = [];
- let cool = 1;
- let sum = 0;
- let string = input[0].split(" ");
- let coolEmojis = [];
- for (const iterator of string) {
- let match = pattern.exec(iterator);
- let thresholdMatches = threshold.exec(iterator);
- if (match != null) {
- emojis.push(match);
- }
- if (thresholdMatches != null) {
- cool *= Number(thresholdMatches);
- }
- }
- console.log(`Cool threshold: ${cool}`);
- for (const el of emojis) {
- let string = el[2];
- for (let i = 0; i < string.length; i++) {
- sum += string.charCodeAt(i);
- }
- if (el === sum) {
- coolEmojis.push(el);
- }
- }
- console.log(
- `${
- emojis.length
- } emojis found in the text. The cool once are: ${coolEmojis.join("\n")}`
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement