Help with an alert message

wxdqz

New Member
I've got a simple rock, paper, scissors javascript that I'd like to post an alert and reset once the total number of wins or losses equals 25.

I've tried a number of different "if ... alert" lines, but don't seem to figure this one out.

Any help would be appreciated.

Here's the script:

---------------------------

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function playGame(choice) {
with (document.game) {
comp = Math.round((Math.random() * 2) + 1);
var choicename;
if (comp == 1) choicename = "rock";
if (comp == 2) choicename = "paper";
if (comp == 3) choicename = "scissors";
msg.value = 'I chose ' + choicename + '. ';
switch(choice) { // calculates score
case 1 : // rock
if (comp == 1) { draw.value++; msg.value += 'A tie. Rock on dude!'; break; }
if (comp == 2) { win.value++; msg.value += 'I got you covered!'; break; }
if (comp == 3) { loss.value++; msg.value += 'Hey -- Give me a break!'; break; }
case 2 : // paper
if (comp == 1) { loss.value++; msg.value += 'I lost to paper -- how sad.'; break; }
if (comp == 2) { draw.value++; msg.value += 'Note to self: we tied.'; break; }
if (comp == 3) { win.value++; msg.value += 'I slice, dice and win!'; break; }
case 3 : // scissors
if (comp == 1) { win.value++; msg.value += 'You have been smashed!'; break; }
if (comp == 2) { loss.value++; msg.value += 'Ouch! Cut it out!'; break; }
if (comp == 3) { draw.value++; msg.value += 'A quick tie -- chop-chop!'; break; }
}
msg.value += ' Go again!';
}
}
// End -->
</SCRIPT>
 
Back
Top