8. What if choice 1 is scissors? HELP!


#1


It is keep saying: Oops, try again. You seem to have something wrong with your code. It threw the following error: ReferenceError: chocie1 is not defined

I don't know what I did wrong! Is it the problem of <3. Call your function and pass in userChoice and computerChoice as your two arguments.>? Because I didn't really understand that part haha


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(chocie1 === "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";
        }
    }
}
compare (userChoice, computerChoice)


#2

Well first off, you did not even have scissors as choice one in any case. Second, you need scissors and rock and scissors and paper to complete the code. I would read back over the instructions given to you in this lesson. From those you should be able to tell what you need to put. However, if not here is a basic outline:

else if(what === "what") {
       if(what === "what"){
       return "what wins";
}
}
else if(whatchoice === "what") {
      if(whatchoice === "what") {
      return "what wins";
}
}
}
// keep your compare here I believe it is fine

#3

Thank you so much!! ;D


#4

No problem! Glad to help! Happy coding! :smiley:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.