maryluis 4 лет назад
Родитель
Сommit
44017db4ec
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      homework5js/script.js

+ 7 - 5
homework5js/script.js

@@ -223,7 +223,7 @@ function chessOneLine() {
     }
     return console.log(string)
 }
-chessOneLine()
+// chessOneLine()
 ///////////////
 
 
@@ -253,26 +253,28 @@ function chess(){
     let x = +prompt("Please write a size of horizontal")
     let y = +prompt("Please write a size of vertical") 
     for(let i = 0; i < y; y--){
-        for(let j = 0; j < x; x--) {
+        for(let j = x; j > 0; j--) {
             if(y % 2 === 0){
-                if(x % 2 === 0) {
+                if(j % 2 === 0) {
                     string += "#";
                 } else {
                     string += ".";
                 }
             } else {
-                if(x % 2 === 0) {
+                if(j % 2 === 0) {
                     string += ".";
                 } else {
                     string += "#";
                 }
             }
         }
+
         desk += string + "\n"
+        string = "";
     }
 console.log(desk)
 }
-// chess()
+chess()
 ////////////