Calculator Project is Fun!

Here’s what I came up with:

I didn’t get too into the CSS, as fancy looking calculators have been done by plenty of people. What I did was focus on the JavaScript.

Calculators are interesting because the buttons are contextual. For instance, if you press a four, you expect to see a four displayed, and if you then press ‘+’ you’d basically expect it to not affect the display at all. But if you press another number and then his ‘+’ again, you’d expect to see a total. What happens if you hit ‘+’ more than once? Or if you hit ‘+’ then ‘-’? What if your answer overflows the display, or if you just type enough numbers to overflow the display? What if you try to divide by zero?

Another thing I added was a clear entry button. This deletes only the most recent number used, and changes both the display and the logging that the challenge specifies.

In all, this challenge was a lot more involved than I thought it would be. I spent about four or five hours on it, and wrote nearly 200 lines of JavaScript to get the behavior I was looking for. I think this was my favorite of the FCC projects so far.

Help me out with this one? I entered exactly that: 1.5 -6 and I see -4.5. Can you let me know the sequence you used that gave you the wrong output?

Awesome, I was able to recreate the bug, thanks! Now to fix it…

I was able to fix it pretty quick once I knew it was there. Thanks again for the spot, that was very helpful. :smiley: