Stuck on Calculator

Ok so it’s been a couple of days and many many tries to build a Calculator with React and Javascript.
I have erased everything and started from zero a couple of times, but I still can’t get my head around the problem. How should I be looking at this problem? I’ve tried strings, arrays, splice methods, push, pop, shift, unshift. The closest I’ve got was 13 test completed.

One of the test that failed was that the calculator had to only consider the last operator entered. I had forgotten about this test item and made my calculator would only accept one operator and delete the previous operator. So I had to go back and rewrite that part of the code.

I could really use some advice.

I think I might have coder’s block.

Posting a link to your repo/code would help identify the problem with your approach. There is no one “right decision” or “one and only correct way to do things”.

1 Like

@NickEU

Ok so I’m almost there. Passed 15 of 16 tests.

13. If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign

SyntaxError: invalid increment/decrement operand

Here is my codepen project: https://codepen.io/ezequiel_/pen/eYOJKaw

I brain is fried, it’s been almost a week that I’m working on this calculator.
Could really use some help.

Thanks!

Thanks for your insight @camperextraordinaire. I will look into this and get back to you.

I finally got all the tests to pass. :sweat_smile: @camperextraordinaire

https://codepen.io/ezequiel_/pen/zYOqBeo