Project Euler JavaScript Solution