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.


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
        <button onClick={this.changeColor}>
          Change color
<Toggle />,


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