Lesson &: what if choice 1 is paper? Good afternoon codemen ... and women. Sorry, but his part is still giving me headache. I cant continue


#1


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

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


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

}
}




Somebody please correct the code for me, kindly. Then, please explain about the choice of the number of curly brackets to use for closing. And I see some people are closing finally with }; please explain to me. Thank you very much in advance.


#2

Lesson 7 not lesson &


#3

must be else if(choice1 === "paper")
2. Don't forget the other }. You have to close the first else if

The right syntaxe is:

var compare = function(choice1, choice2) {
    if(choice1 === choice2) {return "The result is a tie";}
    else if(choice1 === "rock"){
        if(choice2 === "scissors"){
            return "rock wins";
        } // what about if choice2 === "paper"??
    }else if(choice1 === "paper"){
          if(choice2==="rock"){
              return "paper wins";
          }else {
              return "scissors wins";
          }
    } // what about if choice1 === "cissors"??
}

#4

Thanks. Will try it tomorrow and inform you. Have a hood night.


#5

Thank you much. It worked.


#6

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