What if choice one is rock?


#1

followed instructions final lines look like these

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

get this:
SyntaxError: Unexpected end of input

someone help please

edit; figured it out

close topic please


#2

@bitcoder01653,

You have to be aware that you are placing the IF ELSE-IF statement construct

  if (choice1 === choice2) {
      return "The result is a tie!";
  }

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

into the compare =function=

var compare = function(choice1, choice2) {
       //Function-Body
 };

So you will have to add a closing-curly-bracket-}
with which you close the FUNCTION-BODY
at the end of your code.

Please read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on:

  • the creation of the compare function
  • the truth-table
  • the build of the IF ELSE-IF statement structure as part of the compare FUNCTION-BODY
  • the execution of the compare function (keeping in mind that the return statement is used )

#3

the system is not recognizing the exclamation marks ( ! ) at the end of lines: 9 and 12.