What if choice1 is scissors?


#1

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

When I run the program the output at the console is just "Computer: rock" or with scissors or with paper... It does not return the lines which has won. Codecademy says the code is correct, but it doesn't work completely.

Please help!

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

to execute the function, call the function


#3

Oh thats right! I forgot that! Thanks!


#4

everything good now?


#5

Yes, thank you very much!


#6