What's Wrong?


#1

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

Code Academy Returns This Error.

Oops, try again. Your code returned 'The result is a tie!' instead of 'paper wins' when the inputs are paper and rock.

/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34)
{
	computerChoice = "rock";
}
else if(computerChoice <= 0.67)
{
	computerChoice = "paper";
}
else
{
	computerChoice = "scissors";
}
console.log("Computer: " + computerChoice);*/

var compare = function(choice1, choice2)//compare the choices to see who wins
{
    if(choice1 = choice2)//see if its a tie
    {
        return("The result is a tie!")//return "The result is a tie!"
    }
    else if(choice1 = "rock")//if choice1 is rock do
    {
        if(choice2 = "scissors")//if choice2 is scissors do
        {
            return("rock wins")//return "rock wins"
        }
        else //if false do
        {
            return("paper wins")//return "paper wins"
        }
    }
}

If You Can Help Please Do.


#2

You are using the assignment operaor. Use the identity operator, ===. Same applies to the rest of your code.


#3

I Don't Understand, Its Worked Before Like That?
EDT:
NVM It worked


#4

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