JS Calculator challenge, feedback welcome!

JS Calculator challenge, feedback welcome!
0.0 0

#1

Here’s my attempt at the Calculator challenge. It gave me some trouble, but I’m quite happy with how it turned out. :smiley:

Any feedback is welcome. Thanks for your time! :slight_smile:


#2

Hi there again. Since you took your time to check on mine, I will have a go on yours.

First of all. it’s looking good and the basic functions work well.

Just a few things:

  • It shouldn’t accept more than one mathemetical symbol at the time

  • It should be able to calculate decimals (so you have to check your input for decimals)

  • The calculator doesn’t follow the mathematical rules, try 5 + 8 / 2 The answer should be 9.

  • There’s also a thing with your CE function, which is related to the decimals. Try 5 + 0.5 CE 9

The calculator is a bit harder than it looks at first sight. I know, I have been there. :wink:

Keep up the good work and happy coding! :wave:


#3

Thanks for the feedback! I worked a bit more on those points today and I’ve made the changes (updated in CodePen as well):

  • Now the math symbols don’t seem to stack anymore.
  • The CE button removes the whole decimal number now.
  • I’ve overhauled the calculate function so it actually considers order of operations.
  • Also fixed some bugs from clicking the “=” or “.” buttons where they can’t be applied.

And the operations with decimals seem to work fine over here. I’ve changed the big number to display the whole decimal value before being added to the query, though.

There’s just one more thing I’ll try to work in, and that’s making the numbers’ font size scale according to the number and the div’s length. :slight_smile:


#4

Great, you’re almost there just two minor things:

  1. I’m not able to do a calculation with negative numbers (f.e. 5x-9 turns into 5-9)
    2a. Try this one 8+ .9 (turns into 8+9, which should not happen)
    2b. and then push CE and .9 :smiley:

#5

Thanks once again for checking it out! I think those issues should be solved by now, hopefully. x.x

I’ll just play a bit more with the design tomorrow before marking the challenge as done. :slight_smile: