Skip to content
Open
Show file tree
Hide file tree
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
28 changes: 0 additions & 28 deletions 03week/index.html

This file was deleted.

32 changes: 0 additions & 32 deletions 03week/style.css

This file was deleted.

42 changes: 0 additions & 42 deletions 03week/ticTacToe.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,22 @@ function printBoard() {

function horizontalWin() {
// Your code here
for (let i=0; i<3; i++){
if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != ' '){
//console.log("horizontalWin")
return true;
}
}
return false;
}

function verticalWin() {
// Your code here
for (let i=0; i<3; i++){
if (board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[0][i] != ' '){
//console.log(verticalWin)
return true;
}
}
return false;
}

function diagonalWin() {
// Your code here
if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != ' '){
return true;
}
if (board[2][0] == board[1][1] && board[1][1] == board[0][2] && board[2][0] != ' '){
return true;
}
return false;
}

function checkForWin() {
// Your code here
if (horizontalWin()){
console.log(playerTurn + " Wins!");
console.log("horizontalWin");
}
if (verticalWin()){
console.log(playerTurn + " Wins!");
console.log("verticalWin");
}
if(diagonalWin()){
console.log(playerTurn + " Wins!");
console.log("diagonalWin");
}
return true;
}

function ticTacToe(row, column) {
// Your code here
board[row][column] = playerTurn;
checkForWin();
if(playerTurn == "X"){
playerTurn = "O";
}
else{
playerTurn = "X";
}
}

function getPrompt() {
Expand Down