Interest is one of the most important thing in life, everyone should know about it and have idea how to calculate it.

You’ll get charge interest when you want to borrow money, and get interest when you saving money. As most of things in finance - any transactions will have two sides, in this case is the borrower/lender.

I decide to make a interest calculator to remind myself how to calculate the compound interest and learn about React, which is a javascript view framework.

Simple Interest

Imaging you saving £100 for 5 years, and your really generous bank give you 40% interest.

In the banking world, your initial £100 is called Principle. You can calculate the total amount you will get after 10 years.

Year 1 interest: £100 * 40% = £40

Year 2 interest: £100 * 40% = £40

Year 3 interest: £100 * 40% = £40

Year 4 interest: £100 * 40% = £40

Year 5 interest: £100 * 40% = £40

So the total interest the bank give you is 4 * 40 = £160.

Final Value = Principle + Total Interest = 100 + (4 * 40) = £260

Or you can use the formula F = P + rt

  • F = Final Value
  • P = Principle
  • r = Interest rate
  • t = Years

Compound Interest

As you can see from the simple interest, interest is calculated every year, and the interest is calculated from the principle, but what happened to the interest your earned every year, it should be take into account when calculate the next interest, we will have the following if we do that.

Year 1 interest: £100 * 40% = £40 Yearend balance 100 + 40 = £140
Year 2 interest: £140 * 40% = £56 Yearend balance 140 + 56 = £196
Year 3 interest: £196 * 40% = £78.4 Yearend balance 196 + 78.4 = £274.4
Year 4 interest: £274.4 * 40% = £109.76 Yearend balance 274.4 + 109.76 = £384.16

This is the compound interest - you earn interest on the interest you earned. As you can see there is £124.16 difference between simple interest and compound interest calculation.

This is very good thing when you saving money, however if you borrowing, compound interest will make your debt a lot bigger than you think.

If you put the above into formula it will be F = p * (1+r)^t

React App

I wanted to learn React, because it give me different way of thinking how to write app for the web, its reactive which means when one thing changes all other things depend on it will also automatically change, this is really cool, so you don’t have to manually keep track of what’s going on.

Used D3 for draw graph, it can do a lot more, checkout their website, there are lots beautiful visualisations. D3 teach me how to think about data and connections between it and presentation layer like the DOM.

Tools used for the app are webpack - powerful module bundler and provided development server. Babel allow me to write next generation of javascript(ES6) today!

Change the principle, interest rate and years in the demo, you will be amazed how the changes will produce vastly different result.

Things learned

It was discovery process when I tried to learn about compound interest, accidentally had more insight about e which is very interesting.

  • React is amazing!
  • D3 visualisation is very powerful
  • Small insight into state machine that works well with React
  • Webpack, ES6 and Babel javascript
  • Importance of consistance
  • Evertying start small and have potential to get really big
  • Value long term over short term
  • Interesting fun about e - a life constant
  • A small improvment everyday will have huge impact over a long period of time