Render Conditionally from Props 'missing something?'

Render Conditionally from Props 'missing something?'
0

#1

Tell us what’s happening:
What am I missing here? This test is not passing, I have checked for all the syntatical and logical errors.

Your code so far


class Results extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <h1>
      {
       this.props.fiftyFifty > 0.5? "You win!": "You lose!"
      }
      </h1>
    )
  };
};

class GameOfChance extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 1
    }
    this.handleClick = this.handleClick.bind(this);
  }
  handleClick() {
    this.setState({
      counter: 0 // change code here
    });
  }
  render() {
    let expression = null; // 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/68.0.3440.75 Chrome/68.0.3440.75 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/render-conditionally-from-props


#2

One error I can see is you need to increment your counter by 1 here.


#3

Yes, I missed to change the counter, and one more error I can see is this:
let expression = null; // change code here

I seem to remember making those changes in code editor. Strange they don’t show up here. Well, I will make the necessary changes and get back to you. Thanks


#4

You have not followed the instructions. You are supposed to pass in expression as a prop called fiftyFifty to the Results component. You were told that you should use the expression Math.random() > .5 Instead, you pass the value of null to Results, because you never changed the expression in the following line:

let expression = null; // change code here

#5

yes, Randell. I don’t know how I missed those changes. Please see my comments above