Working out answers to the project Euler challenges in Javascript