6. what if choice1 is rock?


#1

where did i go wrong?:

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";
}
}


#2
var compare = function(choice1,choice2) {
    if(choice1 === choice2) {
    return "The result is a tie";
    }
}

your function ends to early her. rather put that second } at the very end of your code so that the else if is included in the function as well.


#6

Sorry ,sir I did not know


#7

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"; 
    }

}

It is my code, but something is wrong : " There was a problem with your syntax". Please, can you help me? Thank you!


#8

You ended compare after the if-statement.


#9

You have a semicolon before the function starts, which should not be there and your function closes before the else if. So better include that part in the function as well.