Hi All, I am having troubles with #11 and #13 of Calculator React project. Can’t figure out how to limit decimals to only 1, and how to make equations use the last operator if entered multiple. I am a beginner, so keeping the code simple. Any tips will be appreciated here
Link to my working calculator without #11 and #13 passing
Welcome to the forums.
You’ve got some code to prevent duplicate zeroes in the changeValue()
function, so you will need to add something similar (maybe a regular expression to count decimal points?) to prevent multiple decimals from being entered. You will also need to do some processing of this.state.display
before you give it to eval()
in equalEval()
to determine which operators are present and what to do according to the specs.
Finally, be careful in your equalEval()
function; you may need to use the state setting function technique to avoid mutating state there.
Good luck.
1 Like
Thank you ! working on it