title: FreeCodeCamp Javascript calculator test suite | I don't know why I can't pass this test
body: <p>So I'm doing that FCC javascript calculator test, and I'm just stuck.</p>
  <p>my code seems to be working but test suite says I'm not getting half of it so I just wanted to ask if you guys can point me to a write direction.</p>
  <p>Also I'm keep getting this msg:</p>
  <pre><code>    Uncaught SyntaxError: Invalid left-hand side in assignment.
  </code></pre>
  <p>But I don't know what it's referring to.</p>
  <pre><code>const equalStyle = {
    height: 120,
    backgroundColor: &quot;#995ba4&quot;,
    bottom:7,
    position:&quot;absolute&quot;
  };
  const clearStyle = {backgroundColor: &quot;#b83146&quot;};
  const equationStyle = {backgroundColor: &quot;#b2b2b2&quot;};
  const equation = /[/*+-]/;
  const confirmEquation = /[/*+-]$/;
  const secondConfirm =/\d[x/+‑*]‑$/;
  const negative = /[-]/;
  const dotTester = /[.]/;
  const prevTester = /^[/*-+]/;
        
  
  class Main extends React.Component{
    constructor(props){
      super(props);
      this.state={
        totalVal:&quot;&quot;,
        testVal:&quot;0&quot;,
        displayVal:&quot;0&quot;,
        prevVal:&quot;&quot;
      }
      this.clickedVal = this.clickedVal.bind(this);
      this.calDisplay = this.calDisplay.bind(this);
    }
    
   calDisplay(val){
      if(this.state.displayVal == &quot;0&quot;){
        if(this.state.totalVal == &quot;&quot;){
          this.setState({
          totalVal: val
          })
        }
      } 
      else{
        this.setState({totalVal:this.state.totalVal + val})
      }
    }
    
    
   clickedVal(e){
      let clickVal = e.target.value;
      if (clickVal==&quot;x&quot;){clickVal = clickVal.replace(&quot;x&quot;, &quot;*&quot;)};
     
      if(this.state.totalVal.includes(&quot;=&quot;)){
        this.setState({
          totalVal:&quot;&quot;,
          testVal:&quot;0&quot;,
          displayVal:&quot;0&quot;
        })
      }
     
    setTimeout(()=&gt;{
        if(this.state.testVal == &quot;0&quot;&amp;&amp;!isNaN(parseInt(clickVal))){
          this.setState({ displayVal:clickVal, testVal:clickVal}, this.calDisplay(clickVal))
        }
        
        else if (!isNaN(parseInt(clickVal))){
        this.setState({ displayVal: this.state.displayVal + clickVal,testVal:this.state.displayVal + clickVal},this.calDisplay(clickVal))
        }
        /*equation stuff*/
        else if(equation.test(clickVal)){
            if(confirmEquation.test(this.state.totalVal)){
                if(negative.test(clickVal)){
                  this.calDisplay(clickVal)
                  this.setState({displayVal: clickVal, testVal:&quot;0&quot;})
                }
             
                else if(secondConfirm.test(this.state.totalVal)){
                    this.setState({
                        displayVal: clickVal, testVal:&quot;0&quot;, totalVal: this.state.totalVal.slice(0, this.state.totalVal.length-2)
                      });
                setTimeout(()=&gt;this.calDisplay(clickVal))
                }
              
                else{
                    this.setState({
                        displayVal: clickVal, testVal:&quot;0&quot;, totalVal: this.state.totalVal.slice(0, this.state.totalVal.length-1)
                    });
                setTimeout(()=&gt;this.calDisplay(clickVal))
                }
            }  
        
          else if (typeof(this.state.prevVal) == &quot;number&quot;  &amp;&amp; this.state.displayVal ==&quot;0&quot;){
              this.setState({displayVal:clickVal, testVal:&quot;0&quot;})
              this.calDisplay(this.state.prevVal+clickVal)
          }
          
          else{
              this.setState({displayVal:clickVal, testVal:&quot;0&quot;})
              this.calDisplay(clickVal);
          }
      }
        
        else if(clickVal == &quot;.&quot;){
          if(confirmEquation.test(this.state.totalVal)){
            this.calDisplay(&quot;0.&quot;)
            this.setState({ displayVal: &quot;0.&quot;, testVal: &quot;0&quot;})
        }
        else if (dotTester.test(this.state.displayVal)){
            this.setState({displayVal: this.state.displayVal ,testVal:this.state.displayVal})
        }
        else{
            this.calDisplay(clickVal);
            this.setState({displayVal: this.state.displayVal + clickVal,testVal:this.state.displayVal + clickVal})
        }
      }
        
        else if (clickVal == &quot;=&quot;){
           
          let result = Math.round(1000000000000 * eval(this.state.totalVal)) / 1000000000000;
          this.setState({
            displayVal: result, testVal:&quot;0&quot;, prevVal:result
          })
          this.calDisplay(&quot;=&quot;+result)
        }
        
        else if (clickVal == &quot;AC&quot;){
          this.setState({
            totalVal:&quot;&quot;,
            testVal:&quot;0&quot;,
            displayVal:&quot;0&quot;,
            prevVal:&quot;&quot;
        })
      }
     })    
    }
    
    render(){
  
      return(
        &lt;div className = &quot;calculatorBody&quot; &gt;
          &lt;OutputDisplay formula = {this.state.totalVal}/&gt;
          &lt;InputDisplay currentValue = {this.state.displayVal} /&gt;
          &lt;Buttons onClick = {this.clickedVal}/&gt;
        &lt;/div&gt;
      )
    }
  }
  
  </code></pre>
  <p><a href="https://codepen.io/arthur-lee945/pen/NWaebeV?editors=0111" rel="nofollow noreferrer">https://codepen.io/arthur-lee945/pen/NWaebeV?editors=0111</a></p>
  <p>This is my codepen for it.</p>