Rock,Paper Scissors error message Unit2 Computer Choice


#1



Unit 2 Computer Choice Part 1 Exercise in Rock Paper Scissors


error message:
Oops, try again. Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important!


I am getting
Oops, try again. Did you set var computerChoice = Math.random() ? The capital 'M' in 'Math' is important!

var rock = "rock";
var paper = "paper";
var scissors = "scissors";

var userChoice = prompt("enter rock,paper or scissors");
var computerChoice = Math.random(); 
if (computerChoice < 0.33 ){
computerChoice= "rock"; 
} 
else if (computerChoice < 0.67){ 
computerChoice= "paper";
} 
else { 
computerChoice= "scissors";
} 
console.log( computerChoice );

var compare = function (player1,player2) {
if(player1 == player2 )
console.log("its a tie!");

else if(player1==rock)
{
if(player2==paper)
console.log(player2+" wins!");
if(player2==scissors)
console.log(player1 +"wins!");
}
else if(player1==paper)
{
if(player2==rock)
console.log(player1 +"wins!");
if(player2==scissors)
console.log(player2 +"wins!");
}
else if(player1==scissors)
{
if(player2==rock)
console.log(player2 +"wins!");
if(player2==paper)
console.log(player1 +"wins!");

}
};

compare(userChoice,computerChoice);


#2

Computer choice part one doesn't require all that.... I'm going to take a wild guess that you copy and pasted someone elses code.


#3

oh sry I left the code I had from before...deleted and kept only the 2 lines..thx