I can't finish the last part


#1






SyntaxError: Unexpected token else

Replace this line with your 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";
    }
    else if (choice1 === "paper") {
    if (choice2 === "rock")
        return "paper wins";
    }
    else{
        return "scissors wins";
    }
    else if (choice1 === "scissors") {
    if (choice2 === "rock")
         return "rock wins";
    }
    else{
         return "scissors wins";
    }
};


#2

so you make an else if to check what choice1 is:

else if (choice1) {

}

inside the else if you nest a if and a else to check for the options of choice2:

else if (choice1) {
   if (choice2){

  } else {

  }
}

see how i did the nesting with all the curly brackets? ({}), check your code and all curly brackets. If you need more help, post an updated version of your code


#3

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