exercise using while/do while loop in JavaScript