Loop followed by a decision

This is a JavaScript program that prompts the user for input. I have inserted some alert() commands in here to show the programmer the progression through the program. This is an excellent debugging tool. It things are not working the way you want them to, put in an alert() and see what is really happening.