6. What if choice 1 is rock?


#1



I have absolutely no idea whats wrong with my code, somebody help!!

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


#2

Hello :slight_smile:

You should close else if (last line of your code) statement with the }, not ).

And you have to close the function definition with } and assignment (var compare =...) with ;.

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";
        }
    } // end of else if
}; // end of function definition and assignment

#3

The last bracket should be curled bracket instead.


#4

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