What if choice1 is paper? frusterated


#1


SyntaxError: expected expression, got keyword 'else' Don't know where I went wrong I followed the instructions as best as I could have rewritten it multiple different ways and now I'm just stumped.


  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";
    }
    
};
compare (userChoice, computerChoice);


#2

You seem to be missing two open curly brackets here:

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

#3

still giving me that same error


#4

You forgot a closing bracket for the same code block I indicated above:

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

Also, remove that compare (userChoice, computerChoice);. It will cause another error. Make sure to have proper brackets!


#5

still getting the same error. it's odd because if I delete the whole bottom part and just leave

if(choice1 === choice2) {
return "The result is a tie!";

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

}
its fine and passes me


#6

So, are you one lesson 6 or lesson 7? The changes I've indicated should work (because I tested it on mine). The indicated part of your code should look like this:

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

Reason why you're having that error is because you didn't put the brackets in properly.


#7

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