What if choice1 is paper? - Step 7


#1

I tried to read the other topics about step 7, but I just don't get what is wrong with my code?

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 if(choice2 === "paper"){
return "paper wins";
}
else if(choice1 === "paper") {

if(choice2 === "scissors") {
    return "scissors wins";

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

This is my code, it keeps saying '' There was a problem with your syntax.''
I really want to understand what is wrong with it


#2

Hi try try to add a } for the closing of the last else if statement


#3

Thank you for the quick response! I just saw it

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

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

You meant it like this right? Or the second

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

if(choice2 === "scissors") {
    return "scissors wins";

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

Either way it keeps saying there is something wrong with my syntax...


#4

Hi here

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

if(choice2 === "scissors") {
    return "rock wins";
} 
else if(choice2 === "paper"){ <== this should be a else statement 
return "paper wins";
}
}

the else statement dont need a condition so try to remove the condition.

else {
  // do Something 
}

#5

It worked! Thanks :smiley: