What is a problem of this code please tell me that my pleasure ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is a problem of this code please tell me that my pleasure ??

https://code.sololearn.com/WcAe0n8Cf2GL/?ref=app

27th Dec 2018, 12:46 PM
Vinod Rawal
Vinod Rawal - avatar
4 Answers
+ 4
thanks a lot all of you
27th Dec 2018, 5:21 PM
Vinod Rawal
Vinod Rawal - avatar
+ 3
The bug is in the checkMove(). You are checking the whole boxes with each other, not the signs in them .
27th Dec 2018, 1:54 PM
Alies
Alies - avatar
+ 2
in line 39 instead of number 5 write number 6 In the checkMove () function, use document.getElementById (...). TextContent; in line 33 remove the second brackets in the winner () function instead of the letter "x" use the variable "sign" the winner () function must be called before the checksign () function line: disp.innerHTML = sign + "turn's ..."; and the line: turn.innerText = sign; - should not be performed after someone wins
27th Dec 2018, 4:10 PM
Игорь Яковенко
Игорь Яковенко - avatar
+ 2
after all the fixes, the code will look like this: let sign = "X"; let disp =document.getElementById("player");  function print(number){     let turn =document.getElementById("r"+ number );     if(turn.innerText == "" && !winner()){         turn.innerText = sign;         if (!winner()){             checksign();             disp.innerHTML =sign + " turn's..";         }     } }     function checksign(){     if (sign== "X")sign="O" ;     else sign = "X" ;     } function getbox(no){     return document.getElementById("r"+no).textContent;   } function checkmove(a,b,c,m){     if(getbox(a)==m && getbox(b)==m && getbox(c)==m  )         return true;     else return false;    }     function winner() {     if (checkmove(1,2,3,sign)|| checkmove(4,5,6,sign)|| checkmove(7,8,9,sign)|| checkmove(1,4,9,sign)|| checkmove(3,4,7,sign)|| checkmove(1,4,7,sign)|| checkmove(2,4,8,sign)|| checkmove(3,6,9,sign)){         disp.innerHTML = sign + " you won ..😃😃😃";         return true;     }     else return false; }
27th Dec 2018, 5:20 PM
Игорь Яковенко
Игорь Яковенко - avatar