8/9Oops, try again. You seem to have something wrong with your code. It threw the following error: ReferenceError: userChoioce is not defined


#1

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

    else if (choice1 === "scissors") {
    if (choice2 === "rock") {
    return "rock wins";
    }
    else {
    return "scissors  wins";
    }
    }
    };
    compare(userChoioce,computerChoice);

#2

There seems to be typo in userChoice. As a general tip a reference error is a real error caused by the interpreter and if any thing else is correct a typo is probably the reason. Also you can mark the specific word and all other instances should get highlighted as well, if one doesn't you found the problem.


#3

now the same code when i try to save submit it tells me: Oops, try again. Your code returned 'paper wins' instead of 'undefined' when the inputs are scissors and rock ..and i have stuck


#4

Well this part of the code seems to be ok so you probably need to post the rest of it as well.


#6

Hope my code here can help you debugging yours,

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 (choice2 === "rock")
return "paper wins"
} else {
return "scissors wins"
}
};


#7

thank you all for the answers ..The problem was in the : else if ("choice1===paper"). I code else if (choice1==="paper") end it worked.