javascript - ReferenceError: Invalid left-hand side in assignment -
my code rock paper scissors game (called toss) follows:
var toss = function (one,two) { if(one = "rock" && 2 = "rock") { console.log("tie! try again!"); } // more similar conditions `else if` };
when enter in parameters
toss("rock","rock")
i error code:
"referenceerror: invalid left-hand side in assignment"
how fix it? error means , other cases when error can happen?
you have use ==
compare (or ===
, if want compare types). single =
assignment.
if (one == 'rock' && 2 == 'rock') { console.log('tie! try again!'); }
Comments
Post a Comment