DEV Community

Cover image for freeCodeCamp's JavaScript Calculator project built in Elm
Dwayne Crooks
Dwayne Crooks

Posted on • Updated on

freeCodeCamp's JavaScript Calculator project built in Elm

I enjoyed thinking my way through this project. To make it a little more challenging I had two additional goals of my own.

  1. To have a clean separation between the UI and the application logic.
  2. To have an example where tests (in spite of types) are helpful in catching bugs.

You can read more of my thoughts here in the project's README.

Here's my demo and the source code.

Whether you choose to just read the code or to build the project you will learn the following:

  1. How to separate UI and application logic via a concrete example.
  2. How to represent a state machine using union types. The state machine is what drives the input to the calculator and it is fully tested.
  3. How to write tests in Elm.
  4. The importance of testing even in a typed functional language.
  5. How to implement a stack.
  6. How to implement the shunting yard algorithm.
  7. A neat algorithm for displaying rational numbers as decimals, for e.g. displaying 1/6 as 0.1(6).
  8. How to iteratively add features to an application, commit by commit.

If you want to learn by doing or even contribute to the project then you can try tackling these issues.

Let me know in the comments if you'd be interested in a more detailed analysis of this project via a tutorial or otherwise.

Top comments (0)