Your code returned 'paper wins' instead of 'scissors wins' when the inputs are paper and scissors. Can't see error?


#1

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

}
i can't see why the answers I have returned are incorrect?


#2

you do not need a ; at the close of your if/ else if/ else statements. This could be throwing your code off. you DO however need one at the close of your function. Hope this helps


#3

Guess this one is evil as = doesn't compare but assigns a value and in this case this leads to choosing this case no matter what choice2 is because any non-empty string has a value of true.


#4

@haxor789 good catch I didn't even see that they were missing several "=" signs in a few of their statements.


#5

ahhhh! completely missed that, thank you :smile: