Critique my calculator project?

Critique my calculator project?
0.0 0

#1

Hi Everyone,

I think I just finished my calculator project. My goal with the project was to do two things: 1) learn about closures, and 2) try to emulate the behavior of a physical calculator as much as possible.

I did calculation chaining a little different from the sample project. Like a real calculator, mine gives a running total as you punch in new operations. It also allows you to repeat the last calculation by hitting the calculate button again.

I tried to keep all the calculator logic in one file (calculator.js) and all the page rendering in a second file (script.js). That plus using closures helped a lot but the code still managed to get pretty messy by the end. :frowning:

I would appreciate any feedback, especially if you find any bugs-- of which i am sure there are many. Theres definitely problems with how it handles large numbers and I chose to just limit the number of digits to 9. Instead I should switch to scientific notation.

Woops almost forgot to post the link:
https://ssbothwell.github.io/FreeCodeCamep-calculator-project/


#2

Hi, it looks nice and seem to work as far as I tested. So, good job! One thing: it is weirdly scaled ( initially ) on mobile.


#3

Thanks for checking it out! To be honest I totally forget to try to make it scale to mobile. I’m really not that interested in making UIs and just copied the interface from OSX’s desktop calculator pixel for pixel. :laughing:

I guess i’ll have to go back through the front end tutorials and try to figure out how to make the UI responsive.


#4

Well you did a great job copying :slight_smile:


#5

works pretty well … couple of things though … its not allowing numbers like .011 etc or 2.011 and its kind of overflowing for things like 7/3 …
One thing i dont like is not showing the operator that was pressed eg press + nothing shows …


#6

Multiple row evaluations doesn’t work. Try 5+5+5.


#7

ahh hmm, I made a bunch of changes before I posted this thread and must have broken something.

Thanks everyone for all the bugs. I’ll try to get some work on it this weekend and fix everything!