Pavel 7 years ago
parent
commit
9b2605dfd2
1 changed files with 29 additions and 1 deletions
  1. 29 1
      js03/js03.md

+ 29 - 1
js03/js03.md

@@ -340,4 +340,32 @@ document.write(str);
 ```
 ### Задание на черный пояс: Электронная гадалка
 
-Делаю
+Еще не закончил 
+
+```javascript
+var histor = [ 1, 1, 1, 1];
+
+var userNumber = +prompt("Введите 0 или 1");
+
+var predictArray = new Array(4);
+for (var i = 0; i < predictArray.length; i++) {
+	predictArray[i] = [];
+	for (var j = 0; j < predictArray.length; j++) {
+		predictArray[i][j] = [];
+		for (var g = 0; g < predictArray.length; g++) {
+			predictArray[i][j][g] = [];
+			for (var c = 0; c < predictArray.length; c++) {
+				predictArray[i][j][g][c] = -1;
+
+			}
+		}
+	}
+}
+
+predictArray[histor[0]][histor[1]][histor[2]][histor[3]] = userNumber;
+histor.push(userNumber);
+histor.shift();
+console.log(predictArray[histor[0]][histor[1]][histor[2]][histor[3]]);
+```
+
+