Meadowlark: Sheffield based computer consultancy

Javascript, JQuery and single page applications (S.P.A)

The investment value calculator below is a little demonstration of the power of Javascript, Scalable Vector Graphic (SVG) and JQuery. The combination of these technologies can be formidable. For a definitive explanation of how investment decisions are calculated by an expert, consult an expert.

Among many other things Javascript can make static pages dynamic, by dynamic, I mean a web page that can change under user control, at say the click of a button. Dynamic page content is something you have come to expect from your desktop applications. For example, field boxes on dynamic pages, might object to incorrect input and respond with error messages. Alternatively, when you have completed a task correctly, you might be provided with some feedback. But Javascript on its own presents its own problems.

Javascript may and often does execute differently on different browsers (with different Javascript engines). The Internet explorer browser and its javascript interpreter is a particular problem, but any non standard browser may exhibit this maverick behaviour. To overcome this problem we have used the JQuery library in addition to Javascript. This maximises the portability of the Javascript code, by replacing javascript calls with jQuery calls. We can therefore be far more confident that every aspect of this page executes correctly on each browser. Furthermore we have user Scalable Vector Graphics, or SVG for short.

The advantage of SVG is that the graphics files are scalable. This has important implications.

As pages shrink and grow (perhaps when they are viewed on different devices, there is a risk that the image contained on that page will become blurred or distorted. Jpeg files for example really only want to be displayed at the resolution at which they were created. SVG files however can be re-sized up or down and yet they do not degrade. This is because they are defined mathematically and rendered by a parser into pixels rather than being rendered directly as pixels.

Investment Value Calculators

The following is a demonstration of the power of dynamic web pages, that use for example Javascript, JQuery and SVG. It clearly demonstrates how investment calculations can be assisted by these technologies.

If you wish to decide which investment project is most worthwhile, then there are a number of means of ranking projects in a more or less robust way.

Pay back period (PBP)

The payback period method or the payback rule as it is sometimes known calculates how long - if a given investment is made - it will take to equal and return the value of that original investment. For example if you invest £100 and receive weekly returns of £20, then after five weeks the investment is fully repaid, and any subsequent income is profit. We would say that the pay back period in this case is five weeks. If you have some idle cash for say six weeks, then the pay back period method may be the best choice as it attempts to get the best investment over a limited time scale - a time scale that perhaps fits in with other separate investment decisions. As a very simple investment-value calculator and has a number of advantages.

It has some disadvantages

A Payback Period Calculator I

Initial investmentFirst returnSecond returnThird returnFourth returnFifth returnSixth return
100202020202020

A Payback Period Calculator II

In the table below, try entering an initial investment and a series of returns to see what pbp is calculated.

Initial investmentFirst returnSecond returnThird returnFourth returnFifth returnSixth return

Internal Rate Of Return (IRR)

The internal rate of return (IRR) assists capital budgeting decisions. It is calculated with this formula:

Initial investmentrate (%)First returnSecond returnThird return

In the above table, set the rate to a value in the range 0 - 100 to get a net present value of around zero, and and thereby try to identify the internal rate of return . It may take many attempts. Also make sure the returns add up to more than the initial investment.

It is used to determine which discount rate makes the present value of anticipated cash flows equal to the initial capital investment, or in other words what must the investment return each year over the projects life such that it breaks even. This is equivalent to a net present value (NPV) of 0.

This is a little more sophisticated than the payback period concept as it takes into account the rate of return in each year.

Net Present Value (NPV)

Discounted cash flow (DCF)