Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 58 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,73 @@ const printBoard = () => {
}

const horizontalWin = () => {
// Your code here to check for horizontal wins

if(board[0][0] == board[0][1] && board[0][0] == board[0][2])
{
return true
}
if(board[1][0] == board[1][1] && board[1][0] == board[1][2])
{
return true
}
if(board[2][0] == board[2][1] && board[2][0] == board[2][2])
{
return true
}
}

const verticalWin = () => {
// Your code here to check for vertical wins
if(board[0][0] == board[1][0] && board[0][0] == board[2][0])
{
return true
}
if(board[0][1] == board[1][1] && board[0][1] == board[2][1])
{
return true
}
if(board[0][2] == board[1][2] && board[0][2] == board[2][2])
{
return true
}
}

const diagonalWin = () => {
// Your code here to check for diagonal wins
if(board[0][0] == board[1][1] && board[0][0] == board[2][2])
{
return true
}
if(board[0][2] == board[1][1] && board[0][2] == board[2][0])
{
return true
}
}

const checkForWin = () => {
// Your code here call each of the check for types of wins

if(horizontalWin() || verticalWin() || diagonalWin())
{
return true;
}
else
{
return false
}

}

const ticTacToe = (row, column) => {
// Your code here to place a marker on the board
// then check for a win
}

board[row][column] = playerTurn

if(playerTurn == "X")
{
playerTurn = "O"
}
else if(playerTurn == "O")
{
playerTurn = "X"
}
}
const getPrompt = () => {
printBoard();
console.log("It's Player " + playerTurn + "'s turn.");
Expand All @@ -64,7 +111,10 @@ const getPrompt = () => {
});
}


// if(checkForWin() == true)
// {
// return playerTurn
// }
// Unit Tests
// You use them run the command: npm test main.js
// to close them ctrl + C
Expand Down