Stuck on lesson 8


#1

8) What if Choice1 is scissors?

THIS IS THE ERROR MESSAGE I AM GETTING
"Make sure to call your compare function with userChoice and computerChoice as the arguments"

What is wrong with my code?

var userChoice = prompt("Do you choose rock, paper or scissors?");
console.log("User Choice: " + userChoice);

var computerChoice = Math.random();
   if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

 function compare(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";
           }
    
    }
    console.log(compare);
};

#2

make sure to place the function call outside the function:

}
   # wrong place
    console.log(compare);
};
# place it here, outside the function

a function call executes the function, so it makes sense to place the function call outside the function

A function call requires parentheses, functioName(), and between the parentheses you can supply the arguments, if you need multiply arguments separate the arguments with a comma (,)


#3

Thanks, I removed it and added "Compare(userChoice, computerChoice)" and that solved it


#4