6. What if choice1 is rock - syntax error


#1


**UPDATE: Never mind I figured it out. I semi-colon'ed when I should have curly-bracket'ed.***

I can't figure out where I'm going wrong here. I skipped ahead to the next exercise to see the answer and still can't figure out what I'm missing. Any help would be greatly appreciated. Thanks!

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


"Oops, try again. There was a problem with your syntax."


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

Please, post link to the lesson, your full code and error message.


#3

Got it. Sorry, I'm new here!


#4

var compare = function(choice1,choice2) {
    if (choice1 === choice2);
    return"The result is a tie!";
} // here you closed your function, remove it please
else if (choice1 === "rock") { // so this line is unexpected
    if (choice2 === "scissors") {
        return "rock wins";
    }
    else {
        return "paper wins";
    }
}

#5

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