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
16 changes: 13 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,26 @@
<div class="container">
<div class="jumbotron">
<h1>Welcome to Tic Tac Toe</h1>
<p>Get ready to play!</p>
<p>Get ready to draw!</p>
<!-- uses the built-in onclick attribute to call the resetBoard function -->
<button onclick="resetBoard()" type="button" class="btn btn-primary btn-lg" name="button">Restart</button>
</div>
<table>
<tr>
<!-- the onclick calls a function called "handleClick" and passes itself to it -->
<td id='top-left' onclick="handleClick(this)" ></td>
<td id='top-middle'></td>
<td></td>
<td id='top-middle' onclick="handleClick(this)" ></td>
<td id='top-right' onclick="handleClick(this)" ></td>
</tr>
<tr>
<td id='middle-left' onclick="handleClick(this)" ></td>
<td id='middle-middle' onclick="handleClick(this)" ></td>
<td id="middle-right" onclick="handleClick(this)" ></td>
</tr>
<tr>
<td id='bottom-left' onclick="handleClick(this)" ></td>
<td id='bottom-middle' onclick="handleClick(this)" ></td>
<td id='bottom-right' onclick="handleClick(this)" ></td>
</tr>
<!-- @TODO create new rows and cells for the rest of your TTT board. -->
<!-- @TODO give each new cell an id & an event listener to call the "handleClick" function -->
Expand Down
5 changes: 3 additions & 2 deletions scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const addMarker = (id) => {
console.log(`Therefore, a "${currentMarker}" should be placed in the square with the id: ${id}`)

// @TODO-2: Build a line of code that will set the innerHTML property of the element that was clicked to the "currentMarker"

document.getElementById(id).innerHTML = currentMarker
// @TODO-2.5: MIX & MATCH, You will need the following pieces of code to build that line:
// = currentMarker
// .getElementById(id)
Expand All @@ -70,6 +70,7 @@ const changeMarker = () => {
} else {
currentMarker = "X"
}
console.log('BEFORE currentMarker:' ,currentMarker)
}


Expand All @@ -86,7 +87,7 @@ const resetBoard = () => {

// @TODO-3: To make your "Restart" button work you'll need to build a line of code here that:
// collects all of the "td" elements into an HTML Collection: https://www.w3schools.com/jsref/dom_obj_htmlcollection.asp
const squares = document.getElementsByTagName("TD")
// @TODO-3.5: MIX & MATCH, You will need the following pieces of code to build that line:
// squares
// .getElementsByTagName("TD")
Expand Down