-
Notifications
You must be signed in to change notification settings - Fork 48
Time - Vicki #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Time - Vicki #25
Conversation
React Tic Tac ToeMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Great work! Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
| if(squares[0][0].value===squares[0][1].value && squares[0][1].value===squares[0][2].value && squares[0][0].value !==""){ | ||
| setWinner(true); | ||
| showWinner("The winner is " + squares[0][0].value); | ||
|
|
||
| } | ||
| else if | ||
| (squares[1][0].value===squares[1][1].value && squares[1][1].value===squares[1][2].value && squares[1][0].value !==""){ | ||
| setWinner(true); | ||
| showWinner("The winner is " + squares[1][0].value); | ||
| } | ||
| else if | ||
| (squares[2][0].value===squares[2][1].value && squares[2][1].value===squares[2][2].value && squares[2][0].value !==""){ | ||
| setWinner(true); | ||
| showWinner("The winner is " + squares[2][0].value); | ||
| } | ||
| else if | ||
| (squares[0][0].value===squares[1][0].value && squares[1][0].value===squares[2][0].value && squares[0][0].value !==""){ | ||
| setWinner(true); | ||
| showWinner("The winner is " + squares[0][0].value); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This certainly works but could be "DRYed" up by setting this up in a loop format.
| [<Square id={squares[0][0].id} value={squares[0][0].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[0][1].id} value={squares[0][1].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[0][2].id} value={squares[0][2].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[1][0].id} value={squares[1][0].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[1][1].id} value={squares[1][1].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[1][2].id} value={squares[1][2].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[2][0].id} value={squares[2][0].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[2][1].id} value={squares[2][1].value} onClickCallback={onClickCallback} />, | ||
| <Square id={squares[2][2].id} value={squares[2][2].value} onClickCallback={onClickCallback} />] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be DRYed up with a loop.
| // When it is clicked on. | ||
| // Then pass it into the squares as a callback | ||
|
|
||
| const changeSquare = (changedSquare)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the program is written, if a play accidentally clicks a space that has already been claimed, they lose their turn. A check could be added to this function to address that.
React Tic Tac Toe
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
useStateconnected?CS Fundamentals Questions
setState-- it must re-render all of the components that now have different content because of that change.What kind of data structure are the components in, and what sort of algorithms would be appropriate for React's code to "traverse" those components?
Speculate wildly about what the Big-O time complexity of that code might be.