Lesson 7: What if Choice 1 is paper? - Need Help!


#1

Lesson 7: what if choice 1 is paper?

code shows syntax error

var compare =function (choice1,choice2)
{ 
    if(choice1===choice2)
    {
    return "The result is a tie!";
    }
    else if (choice1==="rock") 
    {
        if(choice2=== "scissors") 
        {
            return "rock wins";
        }
        else {
            return "paper wins";
        }
    }
  else if (choice1==="paper") 
  {
    if(choice 2==="rock") {
        return "paper wins";
    }
    else {
        return "scissors wins";
    }
  }
};

#2

HI this line

if(choice 2==="rock")

remove the space between choice and 2


#3

sry bro not that easy....put that 2nd part incide your 1st part...
var compare = function (choice1,choice2){
if(choice1===choice2){
return "The result is a tie!"
}
else if (choice1==="rock"){
if (choice2==="scissors"){
return "rock wins"
}else if (choice1="paper"){
if (choice2="rock"){
return "paper wins"
}
else {
return "scissors wins"
}
}
else {
return "paper wins"
}
}
}


#4

spaced removed ! till prob


#5

HI if you have problem with your code you should post it with the error you get ...


#6

There are assignment operators in these lines of code. Did you mean to use comparison operators?


#7

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