-
Notifications
You must be signed in to change notification settings - Fork 0
Class5tictactoe #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Conversation
stu-k
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're so close! Your logic is #solid for checkForWin() and ticTacToe(), you just have to go for it!
| // Your code here | ||
| // Got help from eddy, I do not completely understand yet | ||
| const checkForWin = () => { | ||
| // if (horizontalWin() || verticalWin() || diagonalWin()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do it! This logic is correct, keep going! Just ignore the turncount thing, and if you look at the tests below, they expect checkForWin() to return either true or false.
| // playerTurn = 'X'; | ||
| // } | ||
| // if (board[row][column] === ' ') { | ||
| // board[row].splice(column, 1, playerTurn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using unnecessary methods, set that value = to playerTurn.
| it('should alternate between players', () => { | ||
| ticTacToe(0, 0); | ||
| assert.deepEqual(board, [ ['O', ' ', ' '], [' ', 'X', ' '], [' ', ' ', ' '] ]); | ||
| assert.deepEqual(board, [ ['O', '', ' '], [' ', 'X', ' '], [' ', ' ', ' '] ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the space back! The tests need it! (In board[0][1], I think you accidentally took it out).
| // 10 11 12 | ||
| // 20 21 22 | ||
| const horizontalWin = () => { | ||
| if ((board[0][0] === board[0][1] && board[0][1] === board[0][2]) || (board[1][0] === board[1][1] && board[1][1] === board[1][2]) || (board[2][0] === board[2][1] && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Yes yes! You got the short way to reference three cells. Nice work! I mean, SOLID work!
Checkpoint Rubric
This is the rubric that your instructor will use to grade your checkpoints. Please do not edit.
Checkpoint 1
Checkpoint 2
Checkpoint 3