Javascript Calculator with Shuntyard Algo and Unit Tests

Javascript Calculator with Shuntyard Algo and Unit Tests
0

#1

I have been writing a javascript calculator for about a few weeks. It uses a shuntyard algorithm to do order of operations. Some unit tests I have not finished yet and there is some functionality missing (e.g. no display limitations, some display errors) but the core logic behaves as expected.

My goal was to practice functional-programming principles, TDD, and code organization.

The hardest part in writing this was

  • Writing in a clean concise scalable testable manner
  • Which ES6 syntax I could use for conciseness
  • On a MV* Pattern, deciding the functionality logic on the * pattern
  • Determining the functionality of the render method

Function wise I had these issues

  • Debating on what arguments and parameters functions should have
  • Trying to avoid functions with side effects
  • Trying to avoid multiple return paths in a function
  • Deciding how to group similar functions
  • What I wrote below is pretty sloppy IMO but I need advice on what I can do better

I might have put too many design constraints and over-engineered it poorly, but I’m wondering what design patterns or things I could do to improve it.


#2

My first test: .2+.3=3.2
Another 5 / -3 = 2