What is wrong about this code?


#1

/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/

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

#2

/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/
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!";
      }
   }
};

#4

No problem, I already found the answer


#5

Just for later readers I guess the problem was a } down here:

else if (choice1 === "paper"); { // no semicolons after conditions
        if (choice2==="rock"){
            return "paper wins";
        }
        else {
            return "scissors wins";
        } // here should have been a } to close the else if (choice1 === "paper")
        else if (choice1 === "scissors"); {
        if (choice2==="scissors"){
            return "rock wins";
        }
        else {
            return "paper wins";
        }
    }
    } //then this one would not be neccessary
}

Also might have a look at this post on the semicolon problem:
http://discuss.codecademy.com/t/conditions-blocks-and-semicolons/2176?u=haxor789

@loraldelor

you're missing the else part for choice2 here:

      else if(choice1 ==="rock"){
          if(choice2 ==="scissors"){
          return "Rock Wins!";
        }
      }

and maybe you need to use lower case letters for your output messages e.g. "rock wins!".
@both you can also format your code by using

```

your code

```

this makes it that colorful keeps your formatting and makes it thereby easier to read.