diff --git a/index.html b/index.html new file mode 100644 index 0000000..aa98890 --- /dev/null +++ b/index.html @@ -0,0 +1,22 @@ + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..9b957a5 --- /dev/null +++ b/script.js @@ -0,0 +1,32 @@ +console.log("hello world"); + +// var clearInput = function() { + +// } + +var player1 = "X"; +var player2 = "O"; +var playerTurn = 0; +var squareArray = document.querySelectorAll(".game-square") +console.log(squareArray) + +for ( i = 0 ; i < squareArray.length ; i ++ ) + squareArray[i].addEventListener('click', function(event){ + squareSelected(event); + }); + +var squareSelected = function (event) { + if ( playerTurn == 0 ) { + event.target.innerText = player1; + playerTurn = 1; + console.log(playerTurn); + } + + else { + event.target.innerText = player2; + playerTurn = 0; + console.log(playerTurn); + } + } + +console.log(playerTurn); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..88c4227 --- /dev/null +++ b/style.css @@ -0,0 +1,16 @@ +.game-square { + display: inline-block; + background-color: red; + width: 80px; + height: 50px; + border: 1px solid grey; + margin: 1px; + padding: 1px; + vertical-align: top; + font-size: 43px; +} + +#board { + /*display: grid;*/ + text-align: center; +} \ No newline at end of file