mirror of
https://github.com/FranP-code/Tic-Tac-Toe-Game.git
synced 2025-10-12 23:52:39 +00:00
24 lines
614 B
JavaScript
24 lines
614 B
JavaScript
export default function checkVictory(combinations, boxes, globalBoxesMarked) {
|
|
|
|
const result = []
|
|
|
|
combinations.forEach(combination => {
|
|
|
|
if (boxes.includes(combination[0]) && boxes.includes(combination[1]) && boxes.includes(combination[2])) {
|
|
|
|
console.log('WIN')
|
|
result.push('WIN')
|
|
result.push(combination)
|
|
|
|
}
|
|
|
|
});
|
|
console.log(globalBoxesMarked.length)
|
|
|
|
if (globalBoxesMarked.length === 9 && result.length === 0) {
|
|
|
|
result.push('TIE')
|
|
}
|
|
|
|
return result
|
|
} |