Invalid left-hand side in assignment..whats wrong with my code?


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/0/1?curriculum_id=506324b3a7dffd00020bf661

ReferenceError: Invalid left-hand side in assignment

What seems to be the problem with my code and what does the above mentioned error means?


var compare = function (userChoice,computerChoice)
{
    
    if(userChoice === computerChoice)
    {
        console.log("It's a tie!")
    }
    else if (userChoice = "rock" && computerChoice = "paper")
    {
        console.log("Computer wins");    
    }
    
    else if (userChoice = "scissors" && computerChoice = "paper")
    {
        console.log("User wins");
    }
     else
        {
        console.log("Computer wins")
        }
}
    
console.log("Let's play Rock,Paper & Scissors!")

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random ();


if (computerChoice < 0.33)
{
computerChoice = "rock";
}
else if (computerChoice <= 0.67);
{
computerChoice ="paper";
}
else 
computerChoice (computerChoice => 67);
{
computerChoice = "scissors";
}

console.log (computerChoice)

console.log(compare(userChoice,computerChoice));


#2

when comparing, use two equal signs, which compares the two things (to check if they are equal), a single equal sign assigns a value to a variable


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.