# Jestervae Wants JavaScript Calculator Feedback

Greetings, campers! I’m JesterVae, otherwise known as Johnny V.

I’m mostly finished with my JavaScript Calculator. I’m not proud of the look but I didn’t want to spend too much time primping.

I wanted to do something a little different, and try to create a sort of ‘dummy-proof’ calculator that simply won’t allow you to enter impossible things rather than validating and rejecting.

It was more tedious than I imagined, and there’s still one weird thing I left alone because it does allow the computation: eval() won’t allow you to subtract a negative number (9- -9 is not okay) but it will allow you to add one (9 + - 9 is okay).

Anyway, here’s my calculator.

https://codepen.io/JesterVae/pen/YaMQLd?editors=0011

There are two things I may add in the future:

1. A limit to entries to avoid ugliness as it tries to cram the formula into my fixed
width.
2. Making the current total the first entry of the new formula. As it stands, the formula is maintained until you clear it, but since eval() follows order of operations, the answer may not always be what is expected as the formula gets bigger and more complex.

Feedback is appreciated. Let me know if you find ways to break it. I tried to myself, of course, but I probably missed something. Also, I will comment my code when I’m satisfied with it. Seems like a waste of time when I scrap/rebuild so often as I’m coding.

I initially tried making the enabling/disabling of buttons functions, but it was easier to do the way I did it here. Also, much thanks to Dylan Israel of Coding Tutorials 360 for the basic workings of my calculator.

Thanks for the look.

I’ll take care of those issues, but eval() is always going to follow order of operations, so a long expression won’t evaluate left-to-right. I’ll just make it so the total overwrites the input array when you hit =.

Thanks again.

I can enter multiple initial zeroes, 0000001 etc.

Also, regarding code style, you are putting curly braces on the next line after conditionals and function expressions:

\$("button").on("click", function()
{
if(this.id === "clearAll")
{
inputs = [];
UpdateDisplay();
\$(".totalWindow").html(0);
}

This is not correct style for JavaScript and in some cases can lead to bugs.