Step 9/9 The extra questions


#1

Hello everyone,
So I was attempting to make it so if the game ended in tie, the user would be prompted to choose again? I then would want to the game to re-start itself. I tried to do this by copying and pasting the entire game code under the if statement for a tie. It's not working. Any ideas? The ** bolded section is where I copied and repeated the game.

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function (choice1, choice2) {
if(choice1 === choice2) {
prompt ("Tie, choose again, rock, paper, or scissors?");
(var computerChoice = Math.random();
** if (computerChoice < 0.34) {**
** computerChoice = "rock";**
** } else if(computerChoice <= 0.67) {**
** computerChoice = "paper";**
** } else {**
** computerChoice = "scissors";**
** } console.log("Computer: " + computerChoice);**
** var compare = function (choice1, choice2) {**
** if(choice1 === choice2) {**
** prompt ("Tie, choose again, rock, paper, or scissors?");**
** } **
** else if(choice1 === "rock") { **
** if(choice2 === "scissors") { **
** return "You win";**
** } else {**
** return "The computer wins";**
** } **
** }**
** else if(choice1 === "paper") { **
** if(choice2 === "rock") { **
** return "You win";**
** } else {**
** return "The computer wins";**
** }**
** }**
** else if (choice1 === "scissors") {**
** if(choice2 === "rock")**
** return "You win"**
** else**
** return "The computer wins"**
** }**
** else if (choice1 !== "rock"||"scissors"||"paper") {**
** return "I guess you don't want to play then";**
** }**
** } **
** compare (userChoice, computerChoice);**
}
else if(choice1 === "rock") {

    if(choice2 === "scissors") { 
        return "You win";
    }
    else {
        return "The computer wins";
    }   
}
else if(choice1 === "paper") { 

    if(choice2 === "rock") { 
        return "You win";
    }
    else {
        return "The computer wins";
    }
}
else if (choice1 === "scissors") {
    if(choice2 === "rock")
        return "You win"
    else
        return "The computer wins"
    }
else if (choice1 !== "rock"||"scissors"||"paper") {
    return "I guess you don't want to play then";
}
} 

compare (userChoice, computerChoice);

#2

I would put the original working code in a while loop that has the condition:

while(playerChoice == computerChoice) {