Build rock paper scissors game


I am not sure why my answer is constant scissors instead of getting a random answer for the Math.random().

var userChoice=prompt("Do you choose rock,paper or scissors?");
var computerChoice=Math.random();
if ( 0<computerChoice<0.33 )
{ computerChoice="rock" }
else if 
( 0.34<computerChoice<0.66 )
{ computerChoice="paper" }
( 0.67<computerChoice<1 );
{ computerChoice="scissors" }


else can't have a condition, since its everything else

having too many semi-colons:

( 0.67<computerChoice<1 ); // this one

can also be a problem. Js will understand the comparison you are doing, but recommend is to use the and (&&) operator, if you want to do multiply comparisons. If you think about it, you only need to check one condition. For else if, you don't need to check if the value is greater then .33, give your if condition catches this


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