Pregunta de entrevista de Fidelity Investments

I was supposed to write few small JavaScript programs using JSFiddle