Calculator code challenge solution

I complete this code challenge using with jQuery and Bootstrap 4:

Please test on my webpage.

It is works also with keyboard event… :slight_smile:


Pretty cool, good job! I found only one minor bug: how do I 42/-2?

1 Like

Nice I’m wondering how hard it would be to add functions like figuring %.
Great work I have not gotten this far yet.

Thanks for your response. I checked this ‘minor bug’.
I have windows 10 op. system on my machine. When I developed the calculator I tried to get same functionality like the win 10 calculator. 42/-2 = 40 because the calculator change the operator to the last pressed if been entered more than one. So 42/-2 => 42-2 = 40.
On the calculation field also changed the operator to the last one.
When you enter 42/-2 and press enter or equal
The result is:

  • on calculation field: 42-2=40
  • on display: 40

I don’t handle this result as any bug. This is more like a behavior of some calculators…

But anyway really thanks for your opinion.

My brain nerded out - do you mean a modulo calculation, or a percentage one?

Yes, apple calculator does the same, however it has +/- button for handling negative numbers. I’m pretty sure win 10 calculator has one too :slight_smile:

Anyway it’s fair point!

Yes, there is…
42 - = 0 on win10… strange too.
It’s change the calculation to 42 - 42 = 0

That’s how all hardware calculators work actually, keep pressing = and you will get the idea