Skip to content

Rock - Nyckolle #60

Open
NLucuab wants to merge 3 commits into
Ada-C15:masterfrom
NLucuab:master
Open

Rock - Nyckolle #60
NLucuab wants to merge 3 commits into
Ada-C15:masterfrom
NLucuab:master

Conversation

@NLucuab
Copy link
Copy Markdown

@NLucuab NLucuab commented Jun 26, 2021

Adds logic to turn in, will review example to make sure I understand what syntax does.

Copy link
Copy Markdown

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

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

looks like you are on the right track! We need to pass your updateSquares function as a props through Board in order to get "X" and "O" to display.

The last thing is to show the winner, which it looks like you have in state. All we need to do is display it in the JSX. And your resetGame function looks ready to be used, too.

If you have time to work on this over break I'd encourage you to finish this up! You are almost there!

Comment thread src/components/Board.js
Comment on lines +22 to +38
// let newArr = [];

// for(let i = 0; i < squares.length; i++)
// {
// newArr = newArr.concat(squares[i]);
// }

// // iterate over the new 1D array and insert the squares + id & value
// let squaresArr = [];
// for(let i = 0; i < newArr.length; i++)
// {
// const currentSquare = newArr[i];
// squaresArr.push( <Square value= {currentSquare.value} id={currentSquare.id}/>)
// }
// return squaresArr;
// }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remember to get rid of unused code for the final submission

Suggested change
// let newArr = [];
// for(let i = 0; i < squares.length; i++)
// {
// newArr = newArr.concat(squares[i]);
// }
// // iterate over the new 1D array and insert the squares + id & value
// let squaresArr = [];
// for(let i = 0; i < newArr.length; i++)
// {
// const currentSquare = newArr[i];
// squaresArr.push( <Square value= {currentSquare.value} id={currentSquare.id}/>)
// }
// return squaresArr;
// }

Comment thread src/components/Square.js
Comment on lines +17 to +27
// onClickCallback is passed to Square 1D array from Board.js
// gets called for the specific square that is clicked (hence id specification)
// const onSquareClick = () => {
// props.onClickCallback(props.id);
// };
// // return button with onSquareClick called, with class specification for CSS
// return (
// <button className='square' onClick={onSquareClick}>
// {props.value}
// </button>
// );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
// onClickCallback is passed to Square 1D array from Board.js
// gets called for the specific square that is clicked (hence id specification)
// const onSquareClick = () => {
// props.onClickCallback(props.id);
// };
// // return button with onSquareClick called, with class specification for CSS
// return (
// <button className='square' onClick={onSquareClick}>
// {props.value}
// </button>
// );

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.

2 participants