React Calculator not passing all tests [SOLVED]

Hi. I believe my calculator is functioning correctly. Everything seems to be working correctly. However, I’m not passing all the tests. Tests I’m failing at: #9, #11, #12, #13 and #14. Decimals and operators are seem to be working. I get my results correct, but I don’t know what exactly is wrong with my calculator. Perhaps there is a mistake in my code, but I can’t pinpoint the problem. At this point, I’m stuck, and I don’t know what the problem is.

Here’s the Link:

Don’t feel bad. These are the kinds of mistakes that drive us all crazy.

So, the test code is not triggering the buttons by the numbers written on then but by the ids. Look at this code here:

        <button onClick={this.props.operators} id='add' class="operator" value='+'>+</button>
        <button onClick={this.props.operators} id='subtract' class="operator" value='-'>-</button>
        <button onClick={this.props.operators} id='multiply' class="operator" value='*'>x</button>
        <button onClick={this.props.operators} id='divide' class="operator" value='/'>/</button>
        <button onClick={this.props.numbers} id='seven' value='7'>7</button>
        <button onClick={this.props.numbers} id='five'  value='8'>8</button>
        <button onClick={this.props.numbers} id='nine'  value='9'>9</button>

        <button onClick={this.props.numbers} id='four'  value='4'>4</button>
        <button onClick={this.props.numbers} id='eight' value='5'>5</button>
        <button onClick={this.props.numbers} id='six'   value='6'>6</button>

        <button onClick={this.props.numbers} id='one'   value='1'>1</button>
        <button onClick={this.props.numbers} id='two'   value='2'>2</button>
        <button onClick={this.props.numbers} id='three' value='3'>3</button>

        <button onClick={this.props.numbers} id='zero'    value='0'>0</button>
        <button onClick={this.props.decimal} id='decimal' value='.'>.</button>
        <button onClick={this.props.initialize} id='clear'  value='clear'>AC</button>

        <button onClick={this.props.evaluate} id='equals' value='='>=</button>

See anything funny about the ids? Specifically for 5 and 8?

When I fix that, all your test pass. Your mislabeling of ids on the buttons was just causing the automated test to push the wrong buttons.


Nice catch. Looked over the code couple of times, checked for syntax errors but i didn’t saw that. :+1:

Wow… I can’t believe I did not see that minor mistake. Thanks a lot.

Trust me, there will be a lot more “oh crap, what an idiot I am” moments. It’s a good day at work if I only have three.