Tell us what’s happening:
Your code so far
class Results extends React.Component {
constructor(props) {
super(props);
}
render() {
{/* Change code below this line */}
return (
<h1>{this.props.fiftyFifty ? "you win!": "you lose!"}</h1>
);
{/* Change code above this line */}
}
};
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 + 1 // Change this line
});
}
render() {
const expression = this.Math.random() >= 0.5 ? true : false // Change this line
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 (Linux; Android 10.0; S21 Plus) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.116 Mobile Safari/537.36 EdgA/45.07.2.5059
.
Challenge: Render Conditionally from Props
Link to the challenge: