What if choice1 is paper?


#1


PLS help!!

Oops, try again. There was a problem with your syntax.
Pls help guys... stuck here

Replace this line with your code. 
else if (choice1 ==="paper") {
    if (choice2=== "rock") {
        return "paper wins" ; }
}
else {
    return "scissors wins" ; }
    }


#2

Hi you should remove one } after the if statement.

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

#3

Hi! thanks for your reply. But that did not work too.... :sweat:


#4

Can you post all your code?


#5

I think I have the same problem. This is the whole code. It does not work. (Have in mind, im really new to this).

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

Hi this part you closed the else if statement before...you should close it after the else statement

else if(choice1 === "rock") {
    if(choice2 === "scissors") {
        return "rock wins";
    }
} <== remove this one 
    else {
        return "paper wins";
    }
} <== add one here

Then this part you should add one } at the end for closing the compare function

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

#7

Thanks! That solved it.