Skip to content

Commit cbf867b

Browse files
authored
Update tord.js
1 parent 0e0e7b3 commit cbf867b

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

tord.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
const cars = [1, 2, 3, 4, 5];
2-
const answer = ["T", "o", "r", "y", "n"];
2+
let answer = ["T", "o", "r", "y", "n"];
33
let trys = 0;
44
let wron = 0;
5+
56
function sub() {
6-
trys = trys + 1;
7+
trys += 1;
78
document.getElementById("t").innerHTML = "Trys: " + trys;
8-
for (let x of 5) {
9-
if (document.getElementById(cars[x]).innerHTML == answer[x] & document.getElementById(answer[x]).innerHTML != "solved'") {
10-
wron = wron + 1;
11-
answer[x] = "solved'";
12-
document.getElementById(cars[x]).id = "d";
9+
10+
for (let x = 0; x < 5; x++) {
11+
const carEl = document.getElementById(cars[x]);
12+
const ans = answer[x];
13+
14+
if (
15+
carEl &&
16+
carEl.innerHTML === ans &&
17+
ans !== "solved"
18+
) {
19+
wron += 1;
20+
answer[x] = "solved";
21+
carEl.id = "d";
1322
cars[x] = "d";
1423
}
15-
if (trys < 4 & wron == 5){
16-
document.getElementById("t").innerHTML = "you win";
17-
}
24+
}
25+
26+
if (trys < 4 && wron === 5) {
27+
document.getElementById("t").innerHTML = "You win";
1828
}
1929
}
30+

0 commit comments

Comments
 (0)