Skip to content

Commit 3d3b3f3

Browse files
committed
tic tac toe
1 parent d818cca commit 3d3b3f3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Tic Tac Toe Game/script.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ box.forEach((box) => {
2525
turnX=true
2626
}
2727
box.disabled=true
28+
checkdraw();
2829
checkwinner();
29-
checkdraw();
3030

3131
})
3232

@@ -56,20 +56,19 @@ for(let pattern of winningpattern){
5656

5757
checkdraw=function(){
5858
isdraw=true;
59-
for(i=0;i<9;i++){
59+
for(i=0;i<box.length;i++){
6060
if(box[i].innerText===''){
61-
62-
6361
isdraw=false;
6462
break;
6563
}
64+
6665
}
6766
if(isdraw){
6867
status="draw"
6968
msgprint();
7069
}
71-
7270
}
71+
7372
msgprint=()=>{
7473
if(status==='win')
7574
{
@@ -78,12 +77,11 @@ msgprint=()=>{
7877
}
7978
else if(status==='draw'){
8079
msg.innerText='Game is Draw'
81-
disable();
80+
disable();
8281

8382
}
8483
}
8584

86-
8785
const disable=()=>{
8886
for(let i of box){
8987
i.disabled=true;

0 commit comments

Comments
 (0)