What if choice1 is rock?


#1

I'm not sure what I'm doing wrong... the part up to You got a tie! is correct but the rest apparently isn't. I followed the instructions within the hint box but it keeps telling me my syntax is wrong..

var compare = function (choice1, choice2) {
if (choice1 === choice2)
return "The result is a tie!";
}

else if (choice1 === "rock") {

if (choice 2 === "scissors) { 
    return "rock wins"; 
} 
else { 
    return "paper wins";
}

}


#2

Hi it's missing the open { to your first if statement then you should close your compare function ...just add one } a the end of your code


#3

Thanks... I managed to get through until the end but now it's telling me to call the function and pass in userChoice and computerChoice as the two arguments but it won't let me do it..
I know how to pass simple functions like the sleepcheck one done in an earlier section but this is confusing me.. here's my code:

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";
}
}
else if(choice1 === "scissors") {
if(choice2 === "rock") {
return "rock wins";
}
else {
return "scissors wins";
}
}
};
compare(...
I don't understand what I'm supposed to put in the brackets after the function 'compare'?


#4

in your code, your arguments are currently called choice1 and choice2.


#5

Hi You should Call

compare(userChoice,computerChoice);

With userChoice And computerChoice.


#6

That was the first thing I wrote but I keep getting the message Syntax error: unexpected end of input.

this is the last part of my code
else if(choice1 === "paper") {
if(choice2 === "rock") {
return "paper wins";
}
else {
return "scissors wins";
}
}
else if(choice1 === "scissors") {
if(choice2 === "rock") {
return "rock wins";
}
else {
return "scissors wins";
}
}
}
compare(userChoice, computerChoice);

is that what you mean by compare(userChoice, computerChoice)?


#7

I know that's probably supposed to help but I'm still stuck.. :stuck_out_tongue:


#8

You didn't Closed Your first if statement


#9

ok I've got it... I can't believe I missed that and I went over it to check so many times. Thanks!


#10

Pretend it doesn't say to call the function. When you delete the * / and / *, you're activating var compare. Don't forget to pass in userChoice and computerChoice. :smile: