Created
February 6, 2019 21:48
-
-
Save thiskevinwang/1b75d1acc7ba3ec7d0523fb3657b5568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Board extends React.Component { | |
renderSquare(i) { | |
return ( | |
<Square | |
key={"square " + i} | |
value={this.props.squares[i]} | |
onClick={() => this.props.onClick(i)} | |
/> | |
); | |
} | |
renderSquares(n) { | |
let squares = []; | |
for (let i = n; i < n + 3; i++) { | |
squares.push(this.renderSquare(i)); | |
} | |
return squares; | |
} | |
renderRows(i) { | |
return <div className="board-row">{this.renderSquares(i)}</div>; | |
} | |
render() { | |
return ( | |
<div> | |
{this.renderRows(0)} | |
{this.renderRows(3)} | |
{this.renderRows(6)} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The assignment was to have two for loops, I only see one in your solution.
I've changed renderRows() and render() to meet the requirements