Skip to content

Conversation

adjayanbaeva
Copy link

This project is still in progress.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You almost have this. The detect winner is almost done, just a few typos left. See my feedback here. These kind of changes throughout the checkForWinner function will make it work.

Impressive for starting on Monday.

🟡

The file `package.json` contains details about our project, the scripts available, and the dependencies needed. We can inspect this file when we are curious about the details of our dependencies.

6. Follow the directions in the "Getting Started" section.
6. Follow the directions in the "Getting Started" section.w

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
6. Follow the directions in the "Getting Started" section.w
6. Follow the directions in the "Getting Started" section.

const [currentSquare, setCurrentSquare] = useState(false);

// Wave 2
const changeTheSquare = (id) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice work, very straightforward solution.

// When it is clicked on.
// Then pass it into the squares as a callback

const checkForWinner = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it works to detect a winner. The only problem is that you're using 'X' instead of 'x' etc

let countX = 0;
let countO = 0;
for (let col = 0; col < 3; col += 1) {
if (squares[row][col] === 'X') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of change should be made throughout the function.

Suggested change
if (squares[row][col] === 'X') {
if (squares[row][col].value === PLAYER_1) {

}
}
//Check dioganals
if (squares[0][0] == 'X' && squares[1][1] == 'X' && squares[2][2] == 'X') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch the == use === instead

Suggested change
if (squares[0][0] == 'X' && squares[1][1] == 'X' && squares[2][2] == 'X') {
if (squares[0][0].value === PLAYER_1 && squares[1][1].value === PLAYER_1 && squares[2][2].value === PLAYER_1) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants