Practising Javascript by doing Project Euler