function checkWinner(arr) {
function Eq(a, b, c) {
return a != 0 && a == b && a == c;
}
for (let i = 0; i < 3; i++) {
// check rows
if (Eq(arr[0][i], arr[1][i], arr[2][i])) {
return arr[0][i]
}
// check cols
if (Eq(arr[i][0], arr[i][1], arr[i][2])) {
return arr[i][0]
}
}
// check diagonal
if (Eq(arr[0][0], arr[1][1], arr[2][2])) {
return arr[0][0]
}
if (Eq(arr[0][2], arr[1][1], arr[2][1])) {
return arr[0][2]
}
return 0
}
OFFTOP: шутка на тему tic-tac-toe
https://github.com/asweigart/my_first_tic_tac_toe