What if choice1 is rock? #error


#1

It is my code. Something is wrong :" There was a problem with your syntax". Please help me! Thank you!

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

on this line:

var compare = function(choice1, choice2); {

you have a semi-colon, which means you function will never get executed. Remove the semi-colon, then, you close your function rather quickly:

var compare = function(choice1, choice2){
    if(choice1 === choice2) {
        return "The result is a tie!";
    }
} /* this one closes the function, i suggest you place it after you compared everything */

#3

i have removed it, but it still doesn`t execute..


#4

Did you include your else if inside your function like i told you? Please post an updated version of you code


#5

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

}


#6

see comment:

var compare = function(choice1, choice2) {
    if(choice1 === choice2) {
        return "The result is a tie!";
    }
} /* you close your function here */

your function should be closed after all the comparison (so for know after if else)(aka at the end of your code (for now))


#7

thank you a lot, it has functioned!