8. What if choice1 is scissors? PROMPT ERROR?!?


#1

I have tried and tried with this and cannot seem to figure out what is the problem. I try to run the code and I get this error message:

TypeError: prompt is not a function. (In 'prompt("Do you choose rock, paper or scissors?")', 'prompt' is "Do you chose rock, paper or scissors?")

Here is my code:

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";
                }
            }
else if(choice1==="paper") {

        if(chioce2 === "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

Ok i will figure out your error soon. But PLEASE Do my a favor! Read about THIS Link. Thankyou


#3

Oh perfect! Thanks for the tip.


#4

What browser are you using @puccinin? I litterarly copy pasted your code and it worked. If your not using chrome, can you please try on google chrome and give me back results? Thankyou


#5

I am using Safari. I am using a new MacBook Air. I will download Chrome and try it on there.


#6

Ok It should work there! Normally Javascript since it is not runned in a server on Codecademy will have problems with browser issues. Still get back to me with resilts :smile: And nice MacBook! I wish i had one.


#7

Well thats the problem right there. Thanks for the tip!