Good evening. The code works correctly until you put the character at the end of the listed lines, even if you immediately put it at the end, gives true, I understand this is connected with this part of the code table.rows[k].cells[i].innerHTML=="X" (and all other innerHTML comparisons with "X"). What do i do ?

 function proverka(){ var table = document.getElementById( "myTable" ); var flag; for ( var k = 0; k<tdQuan; k++){ for ( var i = 0; i < tdQuan; i++ ) { for ( var j = 0; j < tdQuan; j++ ) { if (table.rows[k].cells[i].innerHTML == table.rows[k].cells[j].innerHTML && table.rows[k].cells[i].innerHTML=="X" || table.rows[j].cells[k].innerHTML == table.rows[i].cells[k].innerHTML && table.rows[j].cells[k].innerHTML=="X" || table.rows[j].cells[j].innerHTML == "X") flag = true; else { flag = false; continue; } } if (flag === true){alert("победа " ); } } } 

    1 answer 1

     if (...) { alert("победа"); return; } 
    • I have not been able to sleep normally for a week because of this unsolved problem, they helped out, but I was on a different road, thanks Igor - Tigran
    • made a mistake, now it gives out only when you click on the first cell of the first row (even if you click it first) - Tigran