9. Next steps


#1

i'm trying to make it so if they choose the same it asks them to choose another then run the program again, yet i don't know how to get more than one line of code under my if statement :frowning: any help? i have made the part of code i'm referring to into bold for ease of viewing, help is much appreciated.

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)** 
       **userChoice = prompt("It's a tie, choose again!");**
            **compare(userChoice, computerChoice);**

else if (choice1 === "rock")
        if (choice2 === "scissors")
            {return "rock wins";}
        else
            {return "paper wins";}

else if (choice1 === "paper")
        if (choice2 === "rock")
            {return "paper wins";}
        else
            {return "scissors wins";}
        
else if (choice1 === "scissors")
        if (choice2 === "rock")
            {return "rock wins";}
        else
            {return "scissors wins";}        
        }


compare(userChoice, computerChoice)

#2

Well by using {}


Also currently this would be a bit unfair for the computer as you know you tied and and choose again but the computer stays at his choice. Also I'd recommend that you move that tie option outside of the function. For example you could save the output in a variable and if it is tie you let both parties choose again and rerun the function.