Build "Rock, Paper, Scissors"


#1


Good evening,

I am honestly not sure on this one. Any selection I make with my game, I get the following error message: "Oops, try again. Your code returned 'paper wins' instead of 'undefined' when the inputs are scissors and rock".... and I really do not know why.

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
  else if(choice1 === "rock"){
   if(choice2 === "scissors"){
   }
   
   else {
    return ("Paper wins");  
   }
  }
  
  //else if
   else if(choice1 === "paper"){
    if(choice2 === "rock"){
    }
    
    else{
        return("scissors wins");
    }
   }
   
   //else if
   else if(choice1 === "scissors"){
       if(choice2 === "paper"){
       }
       
       else{
           return("paper wins");
       }
 }      
};


#2

Hey you did not included messages insideif's blocks!

if(choice2 === "scissors"){
   }

if(choice2 === "rock"){
    }

if(choice2 === "paper"){
       }

#3

Whoops.... lol. I fixed that and am still getting that same message.


#4

what error youre getting now?


#5

Oops, try again. Your code returned 'paper wins' instead of 'undefined' when the inputs are scissors and rock


#7

If the solution code has been pasted in, in its entirety, it will not pass the second last lesson as the scissors case is not expected yet.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.