![](/img/trans.png)
[英]How to compare two arrays of objects and only remove items from 1st array if 2nd arrays item value says so
[英]how to compare the 2 arrays. 1'st array values which is enter by user and 2'nd are this winningPossibility
const winningPossibility = [
[1,2,3],
[4,5,6],
[7,8,9],
[1,4,7],
[2,5,8],
[3,6,9],
[1,5,9],
[3,5,7]
]
function checkWin(win){
var isEqual = win.every((value) => value === winningPossibility[[0]])
console.log(isEqual)
}
请你比较这两个数组我在我的井字游戏中需要这个东西
你可能想要这样的东西:
function checkWin(win){
return !!winningPossibility.find(possibility => possibility.every(num => win.includes(num)))
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.