JavaScript game based on pure functional programming