This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Arpit satnami
over 8 years

what to do next?? Don't Understand? Help plox>>

this error occured>> “Oops, try again. Make sure to call your compare function with userChoice and computerChoice as the arguments!

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=== “scissors”){ return “rock wins”; } else{ return “paper wins”; } } else if(choice1=== “paper”){ if(choice2===”rock”){ return “paper wins”; } else{ return “scissors wins”; } } else if(choice1===”scissors”){ if(choice2===”rock”){ return “rock wins”; } else{ return “scissors wins”; } } } /Now I call the function and use userChoice and computerChoice as instructed/ prompt(userChoice, computerChoice);

help please

Answer 560e434a95e3782bb0000190

1 vote

Permalink

prompt(userChoice, computerChoice);

here you call prompt. But the name of your function is compare:

compare(userChoice, computerChoice);
points
Submitted by haxor789
over 8 years

1 comments

Arpit satnami over 8 years

Thanks! its working fine.