title: Ternary Operator (Inline If without Else)
body: <p>I have two <code>checkbox</code> in a <code>&lt;form&gt;</code>. The <code>&lt;form&gt;</code> have an <code>onChange={this.checkBoxOnChange}</code> assigned to it which fires up <code>checkBoxOnChange(event){..}</code> function on every change in the form. I am trying to map <em>(Log)</em> the status <em>(ie whether they are checked or not)</em>. So, I've initially taken there value as <code>false</code> as they are not-checked then on each event I'm trying to change there value respectively <em>(ie if false the true &amp; vice versa)</em>.    </p>
  
  <p>On following <a href="https://stackoverflow.com/questions/9232907/can-i-omit-the-else-in-an-inline-javascript-if-statement">this</a> SO post I tried this:       </p>
  
  <pre><code>(event.target.value=='BILLDED') &amp;&amp; billed=(!billed)       
  </code></pre>
  
  <p>By doing this I get: </p>
  
  <blockquote>
    <p>Syntax error: Invalid left-hand side in assignment expression          </p>
  </blockquote>
  
  <p>Then I tried this:        </p>
  
  <pre><code>(event.target.value=='BILLDED') ? (billed=(!billed)) : null        
  </code></pre>
  
  <p>However, it gives me <code>BILLED:true</code> on every <code>onChange</code> (when clicked on BILLED <code>checkbox</code>)<br>
  This is code for checkbox inside render method:       </p>
  
  <pre><code>render() {
      return (
        &lt;div&gt;
        &lt;form onChange={this.checkBoxOnChange}&gt;
          &lt;input type="checkbox" name="invoicestatus" value="BILLDED" /&gt;BILLDED&lt;br /&gt;
          &lt;input type="checkbox" name="invoicestatus" value="PENDING" /&gt;PENDING&lt;br /&gt;
        &lt;/form&gt;
        &lt;ListData data={this.state.data}/&gt;
      &lt;/div&gt;
      );
    }
  </code></pre>
  
  <p>This is the <code>checkBoxOnChange()</code> function within that same class (Component):        </p>
  
  <pre><code>   checkBoxOnChange(event){
      var billed=false;
      var pending=false;
    //  (event.target.value=='BILLDED') ? (billed=(!billed)) : null;
      (event.target.value=='BILLDED') &amp;&amp; billed=(!billed)
    //  (event.target.value=='PENDING') ? pending=(!pending) : null;
      console.log("BILLDED:"+billed+"  PENDING:"+pending);
    }
  </code></pre>
  
  <ul>
  <li>What's wrong with the code?</li>
  <li>Can I not use inline statement for this scenario?</li>
  <li>Is there any better, more concise approach?</li>
  </ul>