Codecademy React.js doubt

0

I am doing the React.js exercises at codecademy.com and got stuck on this issue. I do not know what's wrong and I can not go forward.

    
asked by anonymous 27.08.2016 / 00:12

1 answer

0

Ok, I was curious and I went to look for this exercise in the code academy.

The truth is: your code is right and is a valid way to solve the problem, but the code academy is waiting for something more basic, less correct.

What the site expects / accepts is:

var printS;
if (fiftyFifty) {
  printS = <h1>Tonight I'm going out WOOO</h1>
} else {
  printS = <h1>Tonight I'm going to bed WOOO</h1>
}

return printS;

That is, instead of looking for the chunk of the string that changes with the condition and interpolating as they have in the example TodayPlan.js on the line return <h1>Today I am going to {task}!</h1>; , the exercise goes looking for code in the format I put above. / p>

Remember that Code Academy is a site where a robot analyzes the code inserted. And if no one writes all the possible variants, many of them are left out and test negative.

In short: your way is right and way better than the way the site accepts it.

The code that worked for me:

var React = require('react');
var ReactDOM = require('react-dom');

var fiftyFifty = Math.random() < 0.5;

// React.createClass call begins here:
var TonightsPlan = React.createClass({
  render: function () {
    var printS;
    if (fiftyFifty) {
      printS = <h1>Tonight I'm going out WOOO</h1>
    } else {
      printS = <h1>Tonight I'm going to bed WOOO</h1>
    }

    return printS;
  }
});

ReactDOM.render(
    <TonightsPlan />,
    document.getElementById('app')
);
    
28.08.2016 / 09:34