8. What if choice1 is scissors?


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/5?curriculum_id=506324b3a7dffd00020bf661

My code work correctly, when I choose "rock". If i choose another option (for example "paper"). I get this error:

ReferenceError: choice1 is not defined

what's wrong?

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

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

  
}
}
compare(userChoice,computerChoice)


#2

uhm... i see choise1 and choise2, replace all those with choice1 and choice2.


#3

you have spelled choice as choise in all of your instances. just change them to choice and you should be good to go :slight_smile:


#4

Oh, what a stupid mistake i did))) thank you)


#5

i tracked this mistake, but whatever did( thank you!