Fidelity Investments Interview Question

I was supposed to write few small JavaScript programs using JSFiddle