please have a look on my if condition. I am just refreshing my javascript and I am wondering, how I could check, if the inserted variables, are the ones I want to be used.
Obviously the "game" should only take rock, paper or scissors.
Now the if condition says, if (choice 1 and choice 2 equal rock or scissors or paper) { do this; } else {do something else}
But apparently it is not working the way I want.
var choice1 = prompt("Player 1: Rock, scissors or paper?");
var choice2 = prompt("Player 2: Rock, scissors or paper?");
compare(choice1, choice2);
function compare(choice1, choice2) {
if(choice1 && choice2 === "rock" || "paper" || scissors) {
alert("You pass");
} else {
alert("Something went wrong");
}
Could anyone give me a short explanation, why the if condition passes every value it gets? It never shows the mssage "Something went wrong".