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
18 changes: 14 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ <h1>Welcome to Tic Tac Toe</h1>
<button onclick="resetBoard()" type="button" class="btn btn-primary btn-lg" name="button">Restart</button>
</div>
<table>
<tr>
<tr class="top-row row">
<!-- 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-left' onclick="handleClick(this)"></td>
<td id='top-middle' onclick="handleClick(this)"></td>
<td id='top-right' onclick="handleClick(this)"></td>
</tr>
<tr class="middle-row row">
<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 class="bottom-row row">
<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 Down Expand Up @@ -93,7 +93,8 @@ const resetBoard = () => {
// =
// document
// const

let squares = document.getElementsByTagName("td");

// loops over the HTML Collection of TDs and clears out the Xs and Os
for (i=0; i < squares.length; i++) {

Expand Down