5:7 I got it right but I dont understand

I just don’t get it. The line with “var color = this.state.color == yellow ? green : yellow;”, what the heck is going on here?
The line following I undertand that the state is changing but for some reason this exercise is not sitting right with me. Some please tell me how this entire code works. Well at least the Toggle Component.

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>


var React = require(‘react’);
var ReactDOM = require(‘react-dom’);

var green = ‘#39D1B4’;
var yellow = ‘#FFD712’;

var Toggle = React.createClass({
getInitialState: function(){
return {color:green};
changeColor: function(){
var color = this.state.color == yellow ? green : yellow;
render: function () {
return (
<div style={{background: this.state.color}}>

Change my color

Change color

<do not remove the three backticks above>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.