Render State in the User Interface Another Way - 4th test error


class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'freeCodeCamp'
    }
  }
  render() {
    // change code below this line
  const name= 'freeCodeCamp'

    // change code above this line
    return (
      <div>
        { /* change code below this line */ }
        <h1>{name}</h1>
        { /* change code above this line */ }
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/render-state-in-the-user-interface-another-way/

youā€™ve hardcoded the ā€˜freeCodeCampā€™ string rather than add a reference to it.
Here are the relevant instructions again from the challenge:

define a const called name and set it equal to the name value in the componentā€™s state. Because you can write JavaScript directly in this part of the code, you donā€™t have to enclose this reference in curly braces.

So rather than type the string in, find a way to refer to itā€¦

2 Likes

As @hbar1st mentions, you need to reference 'freeCodeCamp" instead of just assigning ā€˜freeCodeCampā€™ directly to the name variable. Do you see any other code referencing ā€˜freeCodeCampā€™? Go back to the lesson right before this current lesson to see how you could reference the property in state named name.

1 Like