Always tie!


#1


What if choice 1 is scissors?


when i run the code, in any case it results as a tie.


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

console.log(compare());


#2

here:

console.log(compare());

you call the function, but supply no arguments to satisfy function parameters?


#3

but shouldn't they be created by the prompt and the function?


#4

your function has two parameters:

var compare = function(userChoice, computerChoice)

so you will need to supply 2 arguments:

console.log(compare(argument1, argument2));

to satisfy the function parameters


#5

ok got it! thank you very much


#6