34,333
edits
Changes
→JavaScript ''do ... while'' loops
do
{
''JavaScript statement''
} while (''conditional expression'')
</pre>
In the ''do ... while'' example below a prompt dialog will be displayed and the user response assigned to a variable. Until that variable matches the name "John" the loop will continue to display the prompt dialog to the user:
<pre>
do
{
var userResponse;
userResponse = prompt ("Enter your name", "");
} while (userResponse != "John")
</pre>