Advertisement
AlexandrP

Pattern 9

Dec 16th, 2022
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let result = "";
  2. let row;
  3.  
  4. for (row = 1; row <= 5; row++) {
  5.   result = "";
  6.  
  7.   for (column = 1; column <= 5; column++) {
  8.     if ((row == 1 || row == 5) && (column == 1 || column == 5)) {
  9.       result = result + "0";
  10.     } else if ((row == 1 || row == 5) && (column != 1 || column != 5)) {
  11.       result = result + "1";
  12.     }
  13.     if (row != 1 && row != 5) {
  14.       if (column == 2 || column == 3 || column == 4) {
  15.         result = result + "0";
  16.       } else {
  17.         result = result + "1";
  18.       }
  19.     }
  20.   }
  21.   console.log(result);
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement