The game i need to help


#1

var compare = function (user1 user2)
{
if (user1 === user2 )
{ return "same"
}
else if (uesr1 === "rock"){
if (user2 ==="scissors"){
return "rock win"}
else
{ return "scissors win"}
}
else if (uesr1 === "scissors"){
if(user2 === "paper"){
return "scissors win"}
else {
return "paper win"}
}
else if (user1 === "paper"){
if (user2 === "rock"){
return "paper win"}
else{
return "rock win"}
}
};
compare("rock" "rock")


this is my code
is error
can help me


#2

First Mistake

All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created.

That means you have some typos:

var compare = function (user1 user2) //user1
{
if (user1 === user2 )
{ return "same"
}
else if (uesr1 // uesr1

Second mistake
Propertys in a function are comma separated

function x(a,b){
 //code 
}

#3

var compare = function (u1 , u2){
if (u1 === u2)
{
return "same";
}
else if (u1 === "rock")
{
if(u2 === "paper")
}
{
return "paper win";
}
else
{
return "scissors win ";
}
else if (u1 === "paper")
{
if (u2 === "scissors ")
}
{
return "scissors win";
}
else
{
return"rock win";
}
else if (u1 === "scissors")
{
if(u2 === "rock")
}
{
return "rock win";
}
else
{
return "paper win";
}
}
}
compare("paper" , "paper")


thx,help me
i confuse,still mistake


#4

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