Problem with "8. What if choic1 is scissors?"


#1


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


After I enter one of the options I get the error message "Oops, try again.
Make sure to call your compare function with userChoice and computerChoice as the arguments!"

I've checked the code a lot of times and can't find what is wrong.


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 === "paper") {
            return "scissors wins";
        }
        else {
            return "rock wins";
        }
    }
}


#2

You don't need to find what's wrong, the error message is spelling it out for you!


#3

at the very end, you should add a function call:

compare(argument1,argument2)

it is missing in your case, if you don't remember function call revisit that exercise


#4

Thank you, it works now.