[Solved ] Help with JavaScript Calculator from Front End Libraries Certification

Tell us what’s happening:
Hi everyone! Im trying to solve the JavaScript Calculator challenge for the Front End Libraries Certification, but I’m having trouble passing 2 of the tests which are de following:

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

The error displayed is: An input of “5 . 5 . 5” should display 5.55 : expected ‘555’ to equal ‘5.55’

*12. I should be able to perform any operation (+, -, *, /) on numbers containing decimal points

The error displayed is: The expression “10.5 - 5.5” should produce an output of “5” : expected ‘99.5’ to equal ‘5’

But despite of the tests failing, I’ve tried those functionalities manually and they worked fine, literally returning the correct answer. The results end up being exaclty what the error in the tests says it has to be. I have no idea what I’m doing wrong and I would apreciate some help!! I’m really stuck with this.

Your code so far
I’m sorry if my code I’ts kind of messy! But I’ve tried to comment all the most “entangled” parts!

I’m doing this project with React and functional components to learn about hooks in the process.

(Also, the styling isn’t working correctly, for some reason the height of the calculator is not being set. Please ignore that, this is a question for another post :joy:)

Your browser information:

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

Challenge: Build a JavaScript Calculator

Link to the challenge:

----------------------- EDIT: ------------------------

So I’ve finally figure it out, there was some booleans messing with my logic. One of the status I was using to know If de decimal buttons has been pressed was not correctly setted. It was totally a silly-auto-induced bug :sweat_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.