Another useful programming structure is the do...while loop. Unlike the while loop, the do...while loop tests the condition at the end of the code. This means the code will always run at least once.
You guessed my number! <script language="Javascript" type="text/javascript">//declare the guess variable
var guess;
//create a prompt loop
//keep looping until the user guesses the correct number
do
{
guess = window.prompt("Guess a number from 1 to 100", "");
}
while (guess != number)
document.write("You guessed my number!");
</script>