Hey,

First post here. This is a simple game I created within my HTML5 doc. It's "Rock, Paper, Scissors." Can someone tell me why this code runs as it should in FF and Chrome, but not in Safari?

The problem I'm having is that when I run the code, if the user hit's "cancel" before any text is submitted via the prompt, an alert dialogue should show up and say "That's cool." Otherwise, if any text is entered, and the user does not enter either rock, paper or scissors, the dialogue says "I said rock, paper or scissors!" In FF and Chrome, if the user cancels the initial prompt to play the game, it returns "false," the alert "That's cool." appears, and the loop stops. If this is run in Safari, the prompt "I said rock, paper or scissors!" appears.

So...Safari skips the "That's cool" else/if when the initial prompt is cancelled.

Thanks.

<script type="text/javascript">
function runGame()
{
var result = "";

var player = prompt("Pick rock, paper, or scissors.");
if (player !== null) {
player = player.toLowerCase();
}


var choices = ["rock","paper","scissors"];
var computer = choices[Math.floor(Math.random()*3)];

var win = "Your "+player+" beats "+computer+". You win.";
var winScissors = "Your "+player+" beat "+computer+". You win.";
var lose = "Your "+player+" loses to "+computer+". You lose.";
var loseScissors = "Your "+player+" lose to "+computer+". You lose.";
var draw = "A draw: "+player+" on "+computer+".";

if(player === "rock"){
if(computer === "scissors"){
result = win;
}
else if(computer === "paper"){
result = lose;
}
else if(computer === "rock"){
result = draw;
}
}
else if(player === "paper"){
if(computer === "rock"){
result = win;
}
else if(computer === "scissors"){
result = lose;
}
else if(computer === "paper"){
result = draw;
}
}
else if(player === "scissors"){
if(computer === "paper"){
result = winScissors;
}
else if(computer === "rock"){
result = loseScissors;
}
else if(computer === "scissors"){
result = draw;
}
}
else if (player === null) {
alert("That's cool.");
return false;
}
else if (player !== "rock" || player !== "paper" || player !== "scissors") {
result = ("I said rock, paper or scissors!");
}
var repeat = confirm(result + "\n\nDo you want to play again?");
if (repeat === false) {
alert("Thanks for playing!");
}
else {
runGame();
}
}
</script>