0
How do I compare whether a dataset of an array contains in the other javascript array?
Array 1
//Combinações possíveis para acertar a carta
const equals = [
['imgCard_0', 'imgCard_6'],
['imgCard_1', 'imgCard_7'],
['imgCard_2', 'imgCard_8'],
['imgCard_3', 'imgCard_9'],
['imgCard_4', 'imgCard_10'],
['imgCard_5', 'imgCard_11'],
]
Array 2 named rotateCards created dynamically as the user clicks on the chart
["imgCard_0", "imgCard_9"]
I need to check if the two cards clicked by it are in the possible combinations of array 1
tried to do with index, but always returns -1, ie not found.
tried also so const Equal = ! rotateCards.some((val, idx) => val !== equals[idx]), and also unsuccessful so far
I also tried this way without success
for (i = 0; i < equals.length; i++) {
if (clickCard.indexOf(equals[i]) >= 0) {
console.log(equals[i]);
}
}
Image that demonstrates that even though the combination is correct it returns false.
I’ve tried it this way, I don’t know why it always returns false regardless of comparison
– user230033