如何检查“playerChoices”中的数组是否等于“test1”数组中的索引 0。这是我现在的代码。我错过了什么?提前致谢。
var playerChoices = [1, 3];
const test1 = [{right: 1, wrong: 3}, {right: 2, wrong: 1}, {right: 3, wrong: 2}];
function check() {
for (var i = 0; i < test1.length; i++) {
if (test1[i] !== playerChoices[i]) return false;
}
return true;
};
if(check()){
console.log('true');
};