Functional Javascript solutions