Choice1 is rock


#1

hiii please i have a problem and i don't where i am wrong! it says SyntaxError: expected expression, got keyword 'else'

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

else {
    return "paper wins"
};

}
}


Sigh.... Cant seem to get the right code. HELP please
#2

why this lines:

var choice1 = userChoice ;
var choice2 = computerChoice ;

you can just pass this as arguments when calling the function. No need to overwrite the function parameters

this is currently your function:

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

however, all comparison should be part of the compare function


#3

okay thank you so much!!!


#4

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