-
Notifications
You must be signed in to change notification settings - Fork 0
Changes in tictactoe? And PigLatin Application #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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,9 @@ const rl = readline.createInterface({ | |
| output: process.stdout | ||
| }); | ||
| let board = [ | ||
| [' ', ' ', ' '], | ||
| [' ', ' ', ' '], | ||
| [' ', ' ', ' '] | ||
| array1: [' ', ' ', ' '], | ||
| array2: [' ', ' ', ' '], | ||
| array3: [' ', ' ', ' '] | ||
| ]; | ||
|
|
||
| let playerTurn = 'X'; | ||
|
|
@@ -25,14 +25,27 @@ function printBoard() { | |
|
|
||
| function horizontalWin() { | ||
| // Your code here | ||
| if (array1===[x,x,x]||[o,o,o]){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creative approach but you could check against the This will avoid checking for 'o' wins when |
||
| return "Win!"; | ||
| }else if (array2===[x,x,x]||[o,o,o]) { | ||
| return "Win!" | ||
| }else if (array3===[x,x,x]||[o,o,o]) { | ||
| return "Win!" | ||
| } | ||
| } | ||
|
|
||
| function verticalWin() { | ||
| // Your code here | ||
| if (array1[0]===x||o && array2[0]===x||o && array3[0]===x||0){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check against playerTurn here not the literal stings values of |
||
| return "Win!" | ||
| } | ||
| } | ||
|
|
||
| function diagonalWin() { | ||
| // Your code here | ||
| if (array1[0]===x||o && array2[1]===x||o && array3[2]===x||o){ | ||
| return "Win!" | ||
| } | ||
| } | ||
|
|
||
| function checkForWin() { | ||
|
|
||
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.
There's no need to directly manipulate the game's board variable.