8/9 error


#1

This is my code

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 === "rock") {
       return "rock wins";
     }
      else {
        return "paper wins"
   }
 }
}
console.log("The challenger has chosen " + userChoice)
console.log("The computer has chosen " + computerChoice)
compare(userChoice,computerChoice)

When I choose anything it says the right one but it also says "Your code returned 'paper wins' instead of 'undefined' when the inputs are scissors and paper"for the last one and a) I picked rock not paper and b) paper can't win without being there


#2

Have a read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on the truth-table
and look at the required-outcome if
choice1 is "scissors" and choice2 is "paper"


#3

Well have look at what your code does. This above is the code that would handley scissors vs paper and it would return "paper wins". Where the exercise would expect either undefined (because the case is not written yet) or "scissors wins" as... well... scissors beat paper. Maybe really have a look at @leonhard_wettengmx_n truth table if this is still unclear.