I'm trying to check the winner in tic-tac-toe js by using the value of dataset and the index of win combination. maybe i need to compare it I want to use the methods some and every but it does not work.
winCombinations: [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[2, 4, 6],
[0, 4, 8]
]
getWinner(value, player){
let boardCells = document.querySelectorAll('[data-cell]');
return this.winCombinations.some(combination => {
return combination.every(index => {
boardCells.forEach(cell => {
if(cell.dataset.cell.index === 'x'){
console.log('winner!!!')
}
})
})
})
}