Calculator project almost finished just a few questions

Calculator project almost finished just a few questions


Hi just finished the calculator project. If anyone could let me know what they think, any feedback would be appreciated. I tried to test as many edge cases I can think of and I think it works well. My code is super messy though because I didn’t really plan ahead and worked out as I went along so its not really clean code. Just a few questions,

1.)For the functionality I basically hardcoded every possible branch I could think of that a user would do. Is this a normal way to do this assignment?

2.) In css is it possible to give the border of an element a color gradient and rounded edges? I could have it do one or the other but not both.

Thanks in advance.


Why do you show Overflow for 1 divided by 7. It should show 0.14285714285

The same Overflow shows for 1 divided by 3. Any basic calculator can make these calculations. If nothing else you could round to a specific decimal place.

Also, since you use .toString().length <= 10 various times in several if statements, you should consider creating a function to reduce the repetitive code.


I believe its because I hardcoded it so that any number that is longer than 10 digits shows up as overflow. So I think for long decimals I just have to truncate them if they are longer than that.


I think that works pretty well. I notice you stop the user inputting multiple decimal points, which is something a lot of people didn’t cover, and you also allowed for the user to input a negative on the first number if they want to. I just finished this project this week as well, so I get what you mean about not planning it. I did the same, but had to rewrite it in the end. I think you could improve this by upgrading the design a bit with CSS and stuff, maybe sound effects as well. Good project though I think.


Thank you, yeah css stuff in general is something I need to work on. I want my designs to start looking a lot more sleek but its just not there yet. I suppose with time and practice it will get better.