I have somewhat completed my calculator I just need some things such as:
- A function that prevents back to back decimals, and operations
- When I add an operator to a the result of an equation it goes back to the old equation
I really would like to have everyone’s opinion which will help me become a better web developer.
Here’s my project: http://codepen.io/ahenry890/pen/NjBLyY?editors=0100
Hi there, just took a look. One thing I am wondering- is there a reason why you chose to not have the decimal appear until after another numeral is pressed? I thought it wasn’t working at all for a bit.
It’s part of a function that I made to prevent duplicate decimals which isn’t working very well since you are having the problem you just previously stated.
I am also working on this project, and I hadn’t even thought about the need to prevent a repeating decimal point. Oops. Time to go back to my code…
So it seems like you’ll need some kind of function to check if there is a decimal point anywhere in the “calc” variable, and if so, not push anything.
I just worked out a way to do it in mine using the string.includes() method. You can go check out my code if you want- https://codepen.io/paintingfire/pen/ybPOoQ