8/9 Help?


#1

It keeps telling me "Your code returned 'Rock wins' instead of 'undefined' when the inputs are scissors and paper"
And I hardly know what that means, but I DO know that no matter what, it says that rock wins.

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(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";}
    }

else/*scissors*/
    {    
    if(choice2 === "Paper")
        {return "Scissors wins";}
    else
        {return "Rock wins";}
    } 
}

console.log("The challenger has chosen "+ userChoice);
console.log("The computer has chosen " + computerChoice);
compare(userChoice,computerChoice)


#2

You probably need to write them with lower case starting letter "rock" "paper" "scissors"


#3

hey I'm back for more help please, it says i'm missing a ) after argument. I dont understand where that would be?

var compare = function(choice1,choice2){
if (choice1 === choice2) {
return "The result is a tie!";
}
else if (choice1 === "paper") {
if (choice2 === "rock") {
return "paper wins";
}
else (choice2 === "rock")
return "scissors wins";
}
}
var compare = function(choice1,choice2){
if (choice1 === choice2) {
return "The result is a tie!";
}
else if (choice1 === "scissors") {
if (choice2 === "rock") {
return "rock wins";
}
else (choice2 === "paper")
return "scissors wins";
}
}
console.log("The challenger has chosen ""+ "" userChoice);
console.log("The computer has chosen "" + "" computerChoice);
compare(userChoice,computerChoice);


#4

Missing an opening curly bracket here, after "rock") and before return

and opening and closing curly brackets here. I recommend that you put these curly brackets on separate lines so you can see where they line up and then it'll be obvious where you are missing them.

Hope that helps.