Problem 2 with Javascript do-while and for loops