Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.
- What Happens Next? 1:29
- Build the mark() Method
- Build the checkForWin() Method
- get owner() Solution
- checkForWin() Method Challenge Solution
- Build the switchPlayers() Method
- Build the gameOver() Method
- Game Logic Methods Solution 1:56
- Build the updateGameState() Method
- Callback Function Solution
- updateGameState() Method Solution 2:16
- Reviewing 'Adding the Game Logic' 4 questions
Instruction
checkForWin() Method Challenge Solution
checkForWin() Method Solution
/**
* Checks if there a winner on the board after each token drop.
* @param {Object} Targeted space for dropped token.
* @return {boolean} Boolean value indicating whether the game has been won (true) or not (false)
*/
checkForWin(target){
const owner = target.token.owner;
let win = false;
// vertical
for (let x =...