How can I condition my third else if statement based on the result of a for loop?
//If player clicks centre on first move go in corner square
if (current[4] === playerToken && this.state.stepNumber === 1) {
let move = cornerSquares[Math.floor(Math.random() * cornerSquares.length)];
drawSquare(move);
}
//If player clicks corner square on first move go in centre square
else if (this.state.stepNumber === 1) {
for (let i = 0; i < cornerSquares.length; i++){
if (current[cornerSquares[i]] === playerToken) {
drawSquare(4);
}
}
}
//If player or computer has 2 in a row, place in 3rd square to win or block
else if (/*NEED HELP WITH THE CONDITION FOR THIS FOR LOOP*/) {
for (let i = 0; i < twoInRow.length; i++) {
const [a, b, c] = twoInRow[i];
if (current[a] && current[a] === current[b]) {
drawSquare(c);
}
}
}
//Place in random empty square
else {
//code to randomly place x/o in random square
}
}