Strange Result


#1


Rock, paper, scissors


I am having this message from the tutorial instead of moving forward to the next lesson:

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


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(userChoice, computerChoice) {
    if (computerChoice === userChoice){
        return "The result is a tie!";
    }
    else if(computerChoice==="rock"&& userChoice==="scissors" || computerChoice==="paper"&& userChoice==="rock"||computerChoice==="scissors" && userChoice==="paper"){
    return "undefined";
    }
    else{
       
        return "you win";
        }
};

compare(computerChoice, userChoice);


#2

Does not follow the instructions in the slightest. For best results, review the instructions and follow them closely. Don't go it on your own or attempt to jump ahead.


#3

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