I'm trying to make a tictactoe game using javascript. I have the winning conditions in a nested array
const winConditions = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
]
and I have my current player's marked boxes indices in an array
let squaresIndices = [0,4,8]
I'm trying to stop the game when any of the winning conditions occur. I have tried each of the following and I can't figure out why they don't work.
winConditions.forEach((array) => {
if (array === squaresIndices){
alert("Game Over")
}
//////
if (winConditions.includes(squaresIndices)){
alert ("Game Over")
}
//////
winConditions.some((arr) =>{
if (arr.every((square) => {
squaresIndices.includes(square)
})) {
alert("Game Over")
}
})