JavaScript Calculator - Feedback Appreciated


I’ve been working on my JavaScript Calculator Project and would love some feedback!

Link to Codepen

I tried to account for all of the test cases I could think of, but I’m sure I missed some, so please feel free to point those out!

Test cases I tried to account for:

  • cannot have more than one decimal place in a number
  • cannot have more than one negative sign for a number
  • cannot have two or more operators in a row (ex. /+) EXCEPT for one negative sign (ex. 1* -9)
  • after = is pressed, you can use your answer to continue calculating if you click an operator OR start a new expression by clicking a number
  • if a decimal is the first thing clicked for a number, the calculator registers “0.”
  • if a decimal is the only thing clicked between two operators, the calculator registers “0.0”
  • user cannot enter operator first unless it’s a negative sign

Please let me know what you think! Thanks for looking!