Advertisement
diela33

Untitled

Apr 2nd, 2023
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     const regex = /[@#]+([a-z]{3,})[^a-z\d]*\/(\d+)\/[^a-z\d]*[@#]*/gm;
  3.     const eggs = [];
  4.  
  5.     for (let str of arr) {
  6.         let matches = str.matchAll(regex);
  7.         for (let match of matches) {
  8.             const col = match[1];
  9.             const am = parseInt(match[2], 10);
  10.             eggs.push(`You found ${am} ${col} eggs!`);
  11.         }
  12.     }
  13.  
  14.     for (let egg of eggs) {
  15.         console.log(egg);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement