JavaScript code for Project Euler problems