8. What if choice 1 is scissors


#1

I've been trying to go through this line-by-line to figure out what I'm doing wrong, but I'm really stuck.
The prompt box asking what move the user chooses works fine, but when I click OK, I get an error message saying "Oops, try again. Your code returns 'paper wins' instead of 'undefined when the inputs are scissors and rock"


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


#2

Not following the instructions. Go back through them and find your misguided assumptions.


#3

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