Tell us what’s happening:
Hello,
I’m trying to figure out if there’s something wrong with my code or there’s just a big on this challenge. If anyone could take a look at my code, I’d really appreciate it!
Thank you!
Your code so far
class Results extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<h1>
{
this.props.fiftyFifty ? "You win!":"You lose!"
/* change code here */
}
</h1>
)
};
};
class GameOfChance extends React.Component {
constructor(props) {
super(props);
this.state = {
counter: 1
}
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState({
counter: ++this.state.counter // change code here
});
}
render() {
let expression = Math.random() >= .5; // change code here
return (
<div>
<button onClick={this.handleClick}>Play Again</button>
{ /* change code below this line */ }
<Results fiftyFifty={expression} />
{ /* change code above this line */ }
<p>{'Turn: ' + this.state.counter}</p>
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15
.
Challenge: Render Conditionally from Props
Link to the challenge: