What if choice 1 is paper


#1

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

I would like help with my code, the computer keeps saying, "Oops, try again. There was a problem with your syntax." , and I have checked my code a million times and I do not know what is wrong with it. My code is below, and the exercise I'm in is above. Thanks!


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

else if (choice1 === "paper"){
    if (choice2 === "rock"){
        return "paper wins";
}
    else{
        return "scissors wins";
}
}


#2

I can spot one tiny thing missing. I'll give you a hint, it has to do with your function syntax and it's something that is easily forgettable. It is basically the period of Java Script.


#3

I'm sorry to bother you but I still can not find the mistake in my code. Thanks!


#4

Remember that regular function syntax looks like this:


var nameOfFunction = function(parameters of function) {
content of function
};

But you are going like this:

var nameOfFunction = function(parameters of function) {
content of function
}

Notice anything different between the two?


#5

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