For convenience the program should not have to be reloaded each
time where you are running it. So you can take as a Boolean
condition the output of a confirm-command. This command has
a parameter. Use the content of the variable endtext plus
a phrase which tells to click "OK" for continuing the
program. So write something like
do .... while (confirm(endtext+" Press 'OK' to continue"));
at the end of the do-while loop. Delete the command outputting
an alert afterwards.