Need Some Feedback about my JavaScript Calculator

The Project

So here’s the calculator I’ve made: (plain HTML5, plain CSS3, plain JS)

I never thought this project would be real hard in the start. After designing the calculator and diving into the JS, the calculations made my head steam. (Not in the sense that I was angry, tho.)

I tried to cover most of the potential bugs that may arise in the project above. If you have comments or suggestions, feel free to drop them in here. And if you have seen any bugs I haven’t known, feel free to reply me here.

Hints:

Luckily I remembered about the postfix notation and later found the shunting-yard algorithm, to convert any infix notation, e.g. “3 + 5” to its postfix, “3 5 +”. You can check them out if you’re struggling with the calculations, postfix notations make them easier.

There’s also other factors to consider. I found that a lot of potential bugs may arise in this project, without me knowing it. These bugs are actually great lessons.

Example situations that may trigger bugs:

  • Clicking operators (+, -, *, /) more than once,
  • Clicking an operator first instead of a number,
  • Appended more than one decimal point into the display, etc.

That’s all from me. Thank you for reading, guys…

1 Like

Wow! That looks great, and kudos to you for going the extra mile and implementing shunting-yard. I found the bugs you mentioned, but have no solution as it would take a while to walk through your code. Great job, regardless! With these projects, I find that the effort put into them is more important than the final product, so I bet you got a lot more out of your project than I did with mine.

Okay, thanks for your reply, I appreciate it! :smile:

Plus, you’ve relieved me when you said that the process matters more than the final product. Thank you! I always tended to go nuts about the final product, hahaha…

1 Like

It doesn’t work. I tried calculating 98 times by 65 and it doesn’t give me the answer.

Okay, @sikandarali thank you for notifying. But I’ll have to focus on my next projects right now. Given enough time, I’ll look up and debug it.

Once again, thanks for your info.

If anyone else sees another problem, feel free to reply me.

Doesn’t seem to work at all for several pairs of numbers. I don’t think you can call a project finished with significant bugs present. Debugging is half the job after all.

Nonetheless, I like the design and the fact that you didn’t go with eval() like most of us.

Okay @imtoobose , thank you for the reply & advice. There’s gotta be something wrong with my “parser.”