"Rock, Paper, Scissors" Game works, but the software give me a error


#1

Good Night Everyone

My code works, and the game works well, but i can't continue to the next lessons because, the software give me this error...

My Code:

var compare=function(choice1,choice2){
    if(choice1===choice2){
        return "The result is a tie!"
        }
        
    else if(choice1==="rock"){
        if(choice2==="paper"){
            return "paper win the rock, so  COMPUTER WINS";
            }
        else if(choice2==="scissors"){
            return "rock win the scissors, so  USER WINS";
            }
    } 
            
    else if(choice1==="paper"){
        if(choice2==="scissors"){
            return "scissors win the paper so  COMPUTER WINS";
            }
        else if(choice2==="rock"){
            return choice1+" "+"win the "+choice2+" "+", so  USER WINS";
            }
    }  
            
     else if(choice1==="scissors"){
        if(choice2==="paper"){
            return "scissors win the paper, so  USER WINS";
            }
        else if(choice2==="rock"){
            return "rock win the scissors, so  COMPUTER WINS";
            }           
        
        }
    }

confirm("This is a Rock, Paper, Scissors Game, lets play");
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);
  console.log("User: " +userChoice);
  
console.log(compare(userChoice,computerChoice));
confirm("Computer: " + computerChoice+"   "+"User: " +userChoice+"    "+compare(userChoice,computerChoice));

Can anyone help me to solve this problem, please ?

regards :wink:


#2

Have you tried assigning the output of the compare function to a separate variable and then doing a console print of that variable ?
Maybe the course interpreter can't handle the function output inside of the console.log function ?


#3

The only thing that I can see right now is that you changed the output messages, maybe this confuses the test function that expects to the other output messages. The error message is obviously wrong as you called it twice. Is your game working, I mean to you get the expected results?