Need help on step 7


#1

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


#2

Hi try to put all your code and the error that you get when you will put it... in the window where you write on top of it there is a toolbar .. Select all your code and click the one who look like that </>


#3

This part seems to be ok maybe the error is in the other code.


#4

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";}
    if(choice1 === choice2){
    return "The result is a tie!";}
 
    else if(choice1 === "paper") {

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

}

};

#5

it told me this:

Oops, try again. Your code returned 'paper wins' instead of 'scissors wins' when the inputs are paper and scissors


#6

this seems to be the problem with a bit formatting (no fix) it looks like this:

else if(choice1==="rock"){
    if(choice2==="scissors")
        return"rock wins";
}
else {
    return"paper wins";
}
if(choice1 === choice2){
        return "The result is a tie!";
}

As you can see the if lacks its {} which leads to closing the else if to early. So now the else is an alternative to the else if where it should belong to the nested if. And last but not least the copy of the tie case comes really unexpected, you already have one of these. Have a look at what you did for the second else if and fix the first one accordingly.