8.8 What if choice1 is scissors? choice 1 is not defined


#1

8.8 What if choice1 is scissors?

I keep getting the error that "choice1 is not defined". I can not see where my error is!


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";} 


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

compare(userChoice,computerChoice)


#2

if you want to use choice1 and choice2 this should be the function parameters:

var compare = function(userChoice, computerChoice)

your function parameters are different, either rename choice1 and choice2 or rename the function parameters


#3

AH I see the disconnect now. Thank you!!


#4