Got the code mostly right. Needs to return "Rock wins!"


#1

I'm still not sure what I'm doing wrong. The instructions told me to use functions. My code:

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
    return "The result is a tie!";
} else if(choice1 === "Rock") {
    return "Rock wins!";
} else {
    return "Paper wins!";
}
};
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!";
        }
    }
};

Halp, pls!:frowning:


#2

this line:

else if(choice1 = "Rock")

you set choice1 to rock, instead of comparing choice1 with rock (two or three equal signs)


#3
var compare = function(choice1, choice2) {
if(choice1 === choice2) {
    return "The result is a tie!";
} else if(choice1 === "Rock") {
    return "Rock wins!";
} else {
    return "Paper wins!";
}
};

this is a function which is completely irrelevant because this function:

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

directly overwrites it. It even declares compare also it is already declared. And about the interior of the function I'd suggest that you use the second version. With the fix that @stetim94 suggested :slight_smile:


#4

Thank you so much...:confused:


#5

Thank you. It was the "=" signs. Oops!:smiley: