From 1b6ac34461e66ebd8c5a297487ae2e26888196a5 Mon Sep 17 00:00:00 2001 From: Chase Turner Date: Tue, 1 Aug 2017 18:07:51 -0500 Subject: [PATCH] Changes in tictactoe? --- 02week/ticTacToe.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/02week/ticTacToe.js b/02week/ticTacToe.js index 1abf5b900..aeebf2ac6 100644 --- a/02week/ticTacToe.js +++ b/02week/ticTacToe.js @@ -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]){ + 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){ + return "Win!" + } } function diagonalWin() { // Your code here + if (array1[0]===x||o && array2[1]===x||o && array3[2]===x||o){ + return "Win!" + } } function checkForWin() {