Experiments with functional programming in Javascript