Build "Rock, Paper, Scissors" Computer Choice: Part 2


#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 (choice1, choice2)
if (choice1===choice2)
{return "the result is a tie";}
else if (choice1==="rock")
if (choice2==="scissor")
{return "rock wins"}
else {return "paper wins"}
else if (choice1==="scissors")
if (choice2==="paper")
{return "scissors wins"}
else {return "rock wins"}
What did I do wrong


#2

You just have way to much information for this particular lesson. You should really just have like 9 or 10 lines of code for this one. Try going back and simplifying everything to only what the lesson wants.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.