Todorov_Stanimir

06. /last/Wall Builder Text Proces.&Reg.Expr.-More Exercise

Jun 4th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wallBuilder(input) {
  2.     let separator = input.length / 3;
  3.     for (let index in input) {
  4.         if ((Number(index) + 1) / separator <= 1) {
  5.             let pattern = /\b[A-Z]{1,}[0-9]{4,}?([A-Z]{1,}[0-9]{4,})*\b/g;
  6.             if (input[index].match(pattern)) {
  7.                 console.log('SOLID BASE!');
  8.             } else {
  9.                 console.log('WEAK BASE!');
  10.             }
  11.         } else if ((Number(index) + 1) / separator <= 2) {
  12.             let pattern = /^[a-z]{3}[a-z#@$%]+[#@$%]$/gi;
  13.             if (input[index].match(pattern)) {
  14.                 console.log('SOLID MIDDLE!');
  15.             } else {
  16.                 console.log('WEAK MIDDLE!');
  17.             }
  18.         } else if ((Number(index) + 1) / separator <= 3) {
  19.             let pattern = /\b0+([a-z]{0,5}[0])+\1+[a-z]{1,5}\b/g;
  20.             if (input[index].match(pattern)) {
  21.                 console.log('SOLID TOP!');
  22.             } else {
  23.                 console.log('WEAK TOP!');
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment