-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaobancocaro.html
47 lines (42 loc) · 1.19 KB
/
taobancocaro.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h3>Caro Game Simple</h3>
<p id="carogame" />
<input type="button" value="Change Value" onclick="changeValue()">
</body>
<script>
let b = document.getElementById("carogame");
let board = [];
let data = "";
for (let i = 0; i < 5; i++) {
board[i] = new Array(0, 0, 0, 0, 0);
}
for (let i = 0; i < 5; i++) {
data += "<br/>";
for (let j = 0; j < 5; j++) {
data += board[i][j] + " ";
}
}
data += "<br/><br/><input type='button' value='Change Value' onclick='changeValue()'>"
b.innerHTML = data;
function changeValue() {
let positionX = prompt("X: ");
let positionY = prompt("Y: ");
data = "";
board[positionX][positionY] = "x";
for (let i = 0; i < 5; i++) {
data += "<br/>";
for (let j = 0; j < 5; j++) {
data += board[i][j] + " ";
}
}
data += "<br/><br/><input type='button' value='Change Value' onclick='changeValue()'>"
b.innerHTML = "<hr/>" + data;
}
</script>
</html>