8. What if choice1 is scissors?


#1

it's take me "Oops, try again. Make sure to call your compare function with userChoice and computerChoice as the arguments!", but script work!

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 (userChoice===computerChoice) {
return "The result is a tie!";
} else if (userChoice==="rock") {
if (computerChoice === "scissors") {
return "Rock wins";
} else {
return "Paper wins";
}
} else if (userChoice==="paper") {
if (computerChoice==="scissors") {
return "Scissors wins";
} else {
return "Paper wins";}
} else if (userChoice==="scissors") {
if (computerChoice==="rock") {
return "Rock wins";
} else {
return "scissors wins";}
}
};
console.log(compare(computerChoice, userChoice));


#2

when you call the function:

console.log(compare(computerChoice, userChoice));

you swapped them, userChoice should come first.


#3

THX!!! its work! :smiley: