I have this two array: linesToWin and mosseX: []. A possible configuration of mosseX is: mosseX[1,3,4,7]. I want to control if there are three number in mosseX that are equal to an array of linesToWin and return true or false dipending by the searching. Someone could help me?
calculateWinner = () => {
const linesToWin = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6],
];
let result = false;
for (let i = 0; i < linesToWin.length; i++) {
result = this.state.mosseX.filter((mossa) =>
mossa.includes(linesToWin[i].map((u) => u))
);
if (result === true) return result;
}
return result;
};