Advertisement
vallec

stol

Apr 5th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. function checkBossInputs(inputs) {
  2. const numInputs = parseInt(inputs[0]);
  3.  
  4. for (let i = 1; i <= numInputs; i++) {
  5. const bossInfo = inputs[i].trim();
  6. console.log(bossInfo);
  7.  
  8. // Check if boss name and title are valid
  9. const regex = /\|([A-Z]{4,})\|\:\#([A-Za-z]+\s[A-Za-z]+)\#/gm;
  10.  
  11. const match = Array.from(bossInfo.matchAll(regex), res => {
  12. return {name: res[1], title: res[2]}
  13. })[0];
  14. if(match){
  15. console.log(`${match.name}, The ${match.title}\n>> Strength: ${match.name.length}\n>> Armor: ${match.title.length}`);
  16. } else {
  17. console.log("Access denied!");
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement