Ive done it correctly but I dont understand why it wont give out the right output? It keeps saying function


#1

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)
{console.log( "The result is a tie!")}

else if (userChoice === "Rock") {

if(computerChoice === "Scissors")

{console.log( "Rock wins")}

else{console.log( "Paper wins")}}

else if (userChoice === "Paper") {

if(computerChoice === "Rock")

{console.log( "Paper wins")}

else{console.log( "Scissors wins")}

}

else if (userChoice === "Scissors") {

if(computerChoice=== "Rock")

{console.log( "Rock wins")}

else{console.log( "Paper wins")}

}

}
console.log("User:" + " " + userChoice)
console.log( compare)


#2

You're printing the function. Try calling it and printing the result


#3

what do you mean by calling it? im sorry my jargon is not that good


#4

Nvm I fixed it

console.log(compare(userChoice, computerChoice))

instead of console.log( compare)