5. Both choices are the same!


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/1?curriculum_id=506324b3a7dffd00020bf661#

Hello,
I'm having trouble with this piece of code, I am sure it is written correctly but every time I make amendments it still provides me with the same error message: "SyntaxError: Unexpected token"

Solved
I didn't need the ";" after function(choice1, choice2);


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


#3

Hello there, you have an extra semicolon after "function(choice1, choice2)" which shouldnt be there.


#4

Hi, do you know what is wrong with my code?

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


#5

you have an extra curly brackets after "the result is a tie!"
and you have to open a curly bracket after the end of the parameter of else if
heres my code:

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

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