Calculator test 11

I cannot for the life of me get test 11 to pass.

When the decimal element is clicked, a “.” should append to the currently displayed value; two “.” in one number should not be accepted

My calculator does this yet it still does not pass is it because i use eval?
Repo
Calculator

Any help would be much appreciated.

It’s not passing cuz I can hit 2 decimal points and 2 points will appear
You just want one to appear.

Yeah that :point_up:

Oh and don’t forget about this case:
image

See this is what i thought when i was going to originally post. And when i make it so that if the last input was a “.” then it won’t let you put another “.” yet it still fails.

Right now i have it throw an error message and not execute for that case since it wasn’t part of the tests.

You can throw the error, but the tests expect you to have it function like a real calculator, so if somebody did already enter a ., it [edit:] would not let them add another.

Right, caught my mistake and fixed right as you responded.

I added this to my switch and I have redeployed the site with it added

case ".":
          const lastInput = text.slice(-1);
          if (lastInput === ".") {
            this.setState({
              displayText: text,
              input: text
            });
          } else {
            this.setState({
              displayText: text + btn,
              input: text + btn
            });
          }
          break;

it’s not so much the last input. If they entered a decimal point 2 digits ago, would this still work?

Ya I just noticed that I guess I am taking the test case too exact

After getting some sleep I managed to get it to work thanks for the help