the code says :
function checkWinner(cellIndexes, machineAnswers) {
console.log(
`this is the cellIndexes array at the check winner function ${cellIndexes}`
);
console.log(
`this is the cellIndexes array at the check winner function ${machineAnswers}`
);
if (
cellIndexes.includes(1) &&
cellIndexes.includes(2) &&
cellIndexes.includes(3)
)
console.log("the user wins !!!");
else if (
cellIndexes.includes(4) &&
cellIndexes.includes(5) &&
cellIndexes.includes(6)
)
console.log("the user wins !!!");
else if (
machineAnswers.includes(1) &&
machineAnswers.includes(2) &&
machineAnswers.includes(3)
)
console.log("the computer wins wins !!!");
else if (
machineAnswer3.includes(4) &&
machineAnswers.includes(5) &&
machineAnswers.includes(6)
)
console.log("the computer wins !!!");
else console.log("nobody won yet");
}
Even if I got in the console the elements of the two arrays cellIndexes and machineAnswers I still get an error saying
"index.js:1331 Uncaught TypeError: Cannot read properties of undefined (reading 'includes') at checkWinner "
These two arrays hold values so why are they being treated as un undefined variables at this function