What if choice1 is paper?


#1

Help, Please! I know this has been asked before, and I have looked at the other forum posts. I still can't get this to work and I'm not sure what I'm missing.

Syntax error.


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


#2

Use the lower case representations given in the instructions. Remember that computerChoice is rock, paper or scissors and so too should be userChoice. Wait until you complete the module before introducing your own values.


#3

Thanks mtf

I've changed the "rock, paper, scissors" to lower case, and I still get a syntax error. "SyntaxError: missing before statement" is what is showing in my console window.


#4

It looks like you need to close off your compare function.


#5

So, I've updated the code, with the lower case words, and the closing of the compare function. Still no go. :frowning:

Hope this update helps.

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


#6

This line contains an illegal character, ).


#7

Wow! That's all?! Haha. Thank you so much. I guess it pays to walk away from the code for a bit when this kind of thing happens!

Cheers!


#8

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