From 85c1574ed45bbe3268b463d264ecc105fe1600fe Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Sun, 4 Feb 2018 13:13:00 -0600 Subject: [PATCH 1/6] ticTacToe changes --- 03week/ticTacToe.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/03week/ticTacToe.js b/03week/ticTacToe.js index 1abf5b900..627f1b749 100644 --- a/03week/ticTacToe.js +++ b/03week/ticTacToe.js @@ -40,7 +40,8 @@ function checkForWin() { } function ticTacToe(row, column) { - // Your code here + // Your code hererow + console.log(row, column) } function getPrompt() { From 11edb3ccceb2a823bfaa6aae2dbe37ba36fbe683 Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Sun, 4 Feb 2018 14:41:43 -0600 Subject: [PATCH 2/6] horizontal win function --- 03week/ticTacToe.js | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/03week/ticTacToe.js b/03week/ticTacToe.js index 627f1b749..355951d84 100644 --- a/03week/ticTacToe.js +++ b/03week/ticTacToe.js @@ -24,11 +24,19 @@ function printBoard() { } function horizontalWin() { - // Your code here + if([0][0] === playerTurn && [0][1] === playerTurn && [0][2] === playerTurn){ + return true; + } + if([1][0] === playerTurn && [1][1] === playerTurn && [1][2] === playerTurn){ + return true; + } + if([2][0] === playerTurn && [2][1] === playerTurn && [2][2] === playerTurn){ + return true; + } } function verticalWin() { - // Your code here + if([]) } function diagonalWin() { @@ -36,12 +44,32 @@ function diagonalWin() { } function checkForWin() { - // Your code here + } function ticTacToe(row, column) { - // Your code hererow +if (board[row][column] === ' ') { + board[row][column] = playerTurn; +if (checkForWin()){ + +} else { + if (playerTurn === 'X') { + playerTurn = 'O'; + } else { + playerTurn = 'X'; + } + return playerTurn; + } +} + console.log(row, column) + // check if valid input + //check for empty space + //occupy space with X or O + //check for win after marking space + //if win, game is over + //when game is over, reset the board to blank, player turn would start over + //if not a win, switch players } function getPrompt() { From 3568ae7e7ae5863b8cd0f8355e0adb9531b790e9 Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Tue, 6 Feb 2018 18:55:22 -0600 Subject: [PATCH 3/6] tic tac toe --- 03week/ticTacToe.js | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/03week/ticTacToe.js b/03week/ticTacToe.js index 355951d84..4abfc8e48 100644 --- a/03week/ticTacToe.js +++ b/03week/ticTacToe.js @@ -36,22 +36,50 @@ function horizontalWin() { } function verticalWin() { - if([]) + if([0][0] === playerTurn && [1][0] === playerTurn && [2][0] === playerTurn){ + return true; + } + if([0][1] === playerTurn && [1][1] === playerTurn && [2][1] === playerTurn){ + return true; + } + if([0][2] === playerTurn && [1][2] === playerTurn && [2][2] === playerTurn){ + return true; + } } function diagonalWin() { - // Your code here + if([0][0] === playerTurn && [1][1] === playerTurn && [2][2] === playerTurn){ + return true; + } + if([0][2] === playerTurn && [1][1] === playerTurn && [2][0] === playerTurn){ + return true; + } } function checkForWin() { - + if (horizontalWin()) { + console.log(horizontal win); + return "You won!" + } + if (verticalWin()){ + console.log(vertical win); + return "You won!" + } + if (diagonalWin()){ + console.log(diagonal win); + return "You won!" + } } function ticTacToe(row, column) { if (board[row][column] === ' ') { board[row][column] = playerTurn; -if (checkForWin()){ - +if (checkForWin()){ //create reset the board function. + board = [ + [' ', ' ', ' '], + [' ', ' ', ' '], + [' ', ' ', ' '] + ]; } else { if (playerTurn === 'X') { playerTurn = 'O'; From 7f00858fa3f11dcc28fdb45eb101eb3618429708 Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Tue, 6 Feb 2018 19:06:52 -0600 Subject: [PATCH 4/6] first gitOlympics commit --- 04week/gitOlympics.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 04week/gitOlympics.js diff --git a/04week/gitOlympics.js b/04week/gitOlympics.js new file mode 100644 index 000000000..f2afda52b --- /dev/null +++ b/04week/gitOlympics.js @@ -0,0 +1,7 @@ +'use strict' + +const listOfOlympians = ['Bob', 'Joe', 'Tina', 'Sarah', 'Jim']; + +function printListOfOlympians() { + console.log(printListOfOlympians) +} From 62c2a98b83b6dc7360ba636cffae4af6ff83cc51 Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Tue, 6 Feb 2018 19:22:22 -0600 Subject: [PATCH 5/6] second olympians push --- 04week/gitOlympics.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/04week/gitOlympics.js b/04week/gitOlympics.js index f2afda52b..2ca6c7257 100644 --- a/04week/gitOlympics.js +++ b/04week/gitOlympics.js @@ -2,6 +2,8 @@ const listOfOlympians = ['Bob', 'Joe', 'Tina', 'Sarah', 'Jim']; -function printListOfOlympians() { - console.log(printListOfOlympians) -} +function printListOfOlympians = (list) => { +list.forEach(printListOfOlympians(element) { + console.log(element); +}); +} From ae3dcc9914a8cc00ed02179332c7a77dbff8a04f Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Tue, 6 Feb 2018 19:23:08 -0600 Subject: [PATCH 6/6] third olympians push --- 04week/gitOlympics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/04week/gitOlympics.js b/04week/gitOlympics.js index 2ca6c7257..4d01284be 100644 --- a/04week/gitOlympics.js +++ b/04week/gitOlympics.js @@ -6,4 +6,4 @@ function printListOfOlympians = (list) => { list.forEach(printListOfOlympians(element) { console.log(element); }); -} +} printListOfOlympians(listOfOlympians)