What if choice 1 is paper


#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.


expect correct

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


#2

Hi from this part of code I can only see that you closed the else if statement before so you should remove one } after the if statement


#3

OK, here's the whole shebang! The proper placement of the {} is still a mystery to me, esp with the addition of double {{ }}. Can you give me some hints on that?

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


#4

Your code should be like that

else if(choice1 ==="rock") {
    if(choice2 === "scissors") {
        return "rock wins";
    }
} // you should remove tits one because it close the else fi  statement  and put outside the else statement and its give you the erro 
    else {
        return "paper wins";
    }
} // you should close your else if statement here after your else statement

Do the same for the other statement your code code should have tha struttur

1 else if statement

else if (condition) { // open the else if statement 
     if (condition) {  // open the if statement 

    }// close the if statement 

    else {  // open the else statement 


    } // close the  else statement 

} // close the else if statement

2 Then your else if statement with the compare function

var compare = function(choice1 , choice2) { //open the compare function 
    if ( condition) {

    }

    else if (condition) { // open the else if statement 
         If (condition) {  // open the if statement 

         }// close the if statement 

         else {  // open the else statement 


         } // close the  else statement 

    } // close the else if statement 
   // here go all the remain else if statement 
} // here you should close the compare function

In this case if you want to add a else if statement you should add it between the closing of the else statement and the closing of the compare function .
Hope that could help you


#5

Thank you for your help. Positioning the text has been a mystery to me a times. I'm never sure when to indent, when to leave space, when to not leave space. This explanation helps.