Help getting results to display


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/5?curriculum_id=506324b3a7dffd00020bf661

I'm not sure why I can't get the results (ie. "rock wins") to display!

Thanks!


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


#2

Hello @cssace98482,

You aren't getting the result to display because you haven't called your function. In order to display the results, you must console.log the result of calling the compare() function.


#3

Hi you should call the function compare


#4

3:26 am. I guess I'm brain dead sorry for the dumb questions guys.


#5

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