Giter Club home page Giter Club logo

code_test's Introduction

Compensation Calculator

Getting Started

You'll need Node installed. I used v8.1.2.

$ git clone [email protected]:keithbro/code_test.git

$ cd code_test

$ npm install

Running the tests

$ npm test # (uses mocha)

Running the reports

$ ./scripts/payThisWeek.js

Ebony Boycott will get paid $2604.0735 this week
Geoff Rainford-Brent will get paid $1119.026336 this week
Meg Gillespie will get paid $1125 this week
Jason Lanning will get paid $160.022 this week

$ ./scripts/paymentReport.js

# Outputs each payment that a person should have received since their
# injury until now.

Given more time I would...

  • Better input validation! Currently the JSON files must be in the correct format and if they are not you would probably get an ugly error message.
  • Possibly split out calculator.js in to multiple modules, one focused on rules, and another focused on people. Might even be worth turning them in to proper classes, but I went for a more functional approach instead.
  • Move the "scripts" in to their own module so that they can be unit tested.

What I focussed on...

  • Accuracy of calculations. I used Big.js to avoid rounding errors due to working with arbitrary precision decimals.
  • I felt that the mathematical nature of the problem was suited to a functional approach. I focussed on writing small functions and composing them to implement the desired functionality. It was for these reasons that I decided to use JavaScript and the Ramda functional library.
  • Testing. I decided up front which functions I wanted to write and I wrote the tests before writing the implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.