JavaScript beginner: How to restart a loop
<p>Once the user guesses the right number I need to ask if the user would like to play again. As it is the loop will just repeat itself but what I need is the prompt box to ask if you would like to play again. If the user replies yes the loop will initiate again until the answer is guessed</p>

<pre><code>&lt;HTML&gt;    
    &lt;HEAD&gt;    
    &lt;/HEAD&gt;    
    &lt;BODY
        &lt;FORM NAME="testform"&gt;
            &lt;BR&gt;
            &lt;BR&gt;
            &lt;BR&gt;
        &lt;/FORM&gt;

        &lt;INPUT id="attempts" TYPE="text" NAME="inputbox" VALUE="" /&gt;
        &lt;INPUT id="zero" TYPE="button" NAME="resetbox" VALUE="Reset " onclick="reset()" /&gt;

        &lt;SCRIPT type="text/javascript"&gt;
            varattempts = 0;
            x = Math.round((Math.random()*19))+1;
            var tip; 

            tip=prompt("Do you want to play a game?")

            while(tip.charAt(0).toLowerCase() == "y")    
            {    
                var Guess;
                document.getElementById('attempts').value = 0;
                do 
                {    
                    Guess = prompt("Pick a number between 1 and 20","")
                    if (Guess === null) break;
                    document.getElementById('attempts').value = parseInt(document.getElementById('attempts').value)+1
                } while (Guess!=x);

                if (Guess == x)     
                {               
                    alert("You guessed right!")                 
                }
            }               
            function reset()                
            {
                varattempts=0;
                document.getElementById('attempts').value = 'Attempts: 0'; 
            }
        &lt;/SCRIPT&gt;  
    &lt;/BODY&gt;    
&lt;/HTML&gt;
</code></pre>
