Advertisement
kstoyanov

02. Boss Rush js exam

Aug 11th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.   const input = args.slice(1);
  3.   const regPat = /\|(?<boss>[A-Z]+){4}\|(:)(#)(?<title>[A-z]+\s[A-z]+)(#)/g;
  4.  
  5.  
  6.   input.forEach((line) => {
  7.     if (regPat.test(line)) {
  8.       line = line.replace(/[|#]/g, '');
  9.       const [bossName, title] = line.split(':');
  10.  
  11.       console.log(`${bossName}, The ${title}`);
  12.       console.log(`>> Strength: ${bossName.length}`);
  13.       console.log(`>> Armour: ${title.length}`);
  14.     } else {
  15.       console.log('Access denied!');
  16.     }
  17.   });
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement