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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -