JSFiddle - React, Tailwind, and code Playground
by kkdaily
JavaScript
// tic-tac-toe win conditions:
// diagonal starting from the first element in the first row, to the last element in the last row
// vertical, starting from the nth element in the first row, to the nth element in the last row
// horizontal starting from the first element in the nth row, to the last element in the nth row
const checkIfWon = (board) => {
return hasDiagonal(board) || hasHorizontal(board) || hasVertical(board);
}
const hasDiagonal = (board) => {
for (let rowIndex = 0; rowIndex <= board.length; rowIndex++) {
const row = board[rowIndex];
for ()
}
}