Functional programming with JavaScript