Declarative Vs. Imperative Functions in Javascript 