What am I not seeing?


#1



I don't know what I am not seeing, its letting me know that its saying rock wins, but should be undefined.


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 win"
            }
        }
        else if (choice1 === "scissors") {
            if(choice2 === "paper") {
                return "rock wins";
            }
            else {
                return "scissors wins"
            }
        }
    
}
compare(userChoice, computerChoice)


#2

if the user (choice1) choice scissors, and the computer (choice2) choices paper. Rock wins??? So the choice no one picks wins? that doesn't make sense. I think you swapped them. scissors should win, else rock should win (since then choice2 was rock)

This the code i am talking about:

        else if (choice1 === "scissors") {
            if(choice2 === "paper") {
                return "rock wins";
            }
            else {
                return "scissors wins"
            }
        }

#4

Thanks! Wow thought I would not see that for another 2 hrs