What if the Choice1 is "rock"?


#1


What if the Choice1 is "rock"?

Oops! Tray again!! There was a problem with your syntax!
This is a Problem I am facing. Can someone help me, pls :slightly_smiling: ?

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){
        return "The result is a tie!";
        };
     else if(choice1 === "rock"){
        if(choice2 === "scissors"){
            return "rock wins";
            };
            else{
            return "paper wins";    
                };
            };
};
compare('userChoice','computerChoice');


#2

Hi here

compare('userChoice','computerChoice');

Remove the ' ' around userChoice and computerChoice.


#3

Hi, thanks a lot , But it didn't work :slightly_smiling:


#4

Here

if (choice1===choice2){
        return "The result is a tie!";
        }; <== this
     else if(choice1 === "rock"){
        if(choice2 === "scissors"){
            return "rock wins";
            }; <== this
            else{
            return "paper wins";    
                }; <=== this
            }; <== this
};

You should remove all the ; at your closing }


#5

thank you, it really helped!!!