Hello Everyone! can you please help me to solve this algorithm…
My goal is to iterate 2 Arrays and compare them to find out if values from a single Array like: [0, 2, 1] are the same to one of this Sub Arrays: [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6],…
On this case it should return true bacause [0, 2, 1] and [0, 1, 2] have the same values: 0, 1, 2.
Here is an Exemplo code to this problem:
let clicksPlayerO = [0, 4, 3];
const gameWinner = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[3, 4, 5],
[6, 7, 8],
[0, 4, 8],
[6, 4, 2]
];
if(clicksPlayerO.length >= 2){
console.log('Array length: ' + clicksPlayerO + ' length is bigger or iqual than 2!');
//is some of this values: [0, 2, 1] equal to this one of arrays values: [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [3, 4, 5]
// this should be true because both array has same numbers: [0, 2, 1] and this [0, 1, 2]
}else{
console.log('Array length: ' + clicksPlayerO + ' length is smaller than 2!');
}
This logic I would like to use for a TicTacToe game.
Here is the Link where I currently worrking :