js loops and control