7. What if choice1 is paper


#1


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

The code will pass like this, but its wrong. The else if statement is missing an opening curly bracket.

var compare = function(choice1,choice2)  {
    
    if (choice1 === choice2)  {
        return "The result is a tie!";
    
    } else if  ( choice1 === "paper") 

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

SyntaxError: Unexpected end of input
This is the code I think should pass but does not.

var compare = function(choice1,choice2)  {
    
    if (choice1 === choice2)  {
        return "The result is a tie!";
    
    } else if  ( choice1 === "paper") {

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

#2

@tonysgarcia,

var compare = function(choice1,choice2) {

You are placing the IF ELSE-IF statement structure

    if (choice1 === choice2)  {
        return "The result is a tie!";
    
    } else if  ( choice1 === "paper") {
              if ( choice2 === "rock") {
                  return "paper wins";
        
              } else {
                  return "scissors wins";
              }      
     }

into the FUNCTION-BODY of the compare =function=

var compare = function(choice1,choice2)  {
       //Begin of FUNCTION-BODY

       //Here your IF ELSE-IF statement structure

      //End of FUNCTION-BODY
 };

#3

I followed the hint's format. I am still cnousfed.


#4

@tonysgarcia,
at the end of the compare function you will want to have 3 closing-curly-brackets-}
2 for the ELSE-IF and 1 to close the FUNCTION-BODY....


#5

Thanks 'ole G. Thanks for bringin' good info.