My React Calculator app for some reason is failing tests #9 and #11-15


I’m finishing up my work on React Calculator as part of the Front-End Certificate and for some reason it is failing 6 tests. Visually it seems to be working just fine, but it still bugs me that tests are failing. I tried also manually replicating the tests and it worked all fine for me.

What could be an issue with my code?

Here is my pen.

Best regards,


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Build a JavaScript Calculator

Link to the challenge:


A couple of things.

  • Try entering 5..0 into the calculator.
  • It looks like the tests might be reading the first line instead of the second line, resulting in errors.
1 Like


Thank you for your reply! I have managed to fix this first issue and some other bugs that I had in my code. Now it is passing test #11.

However, every other test is still failing. I also think that it might be reading a wrong line of code and resulting in those errors but not sure why it would be doing that.

I have the total final result being saved into displayNum variable via React hook and it is going directly into the element with id="display".

function Display() {
  const { calcRow, displayNum } = React.useContext(Context)
  return (
    <div id="display-container" className="grid-display">
      <p id='formula-display'>{calcRow}</p>
      <p id="display">{displayNum}</p>

I also tried to change things around, as moving id to other elements of this component, but result remains the same.


You should display everything in one <p> tag using \n for the second line to pass the tests. I had same tests failing when forking my calculator.

It seems that a problem had to do with something different and my calculator was indeed not working correctly in some instances (logical error in my functions). Works now though.

Thank you!